On 23/11/2009, at 11:42 AM, PCWiz wrote:

> First of all, you would need to keep a reference to the controller object 
> inside the panel itself. I'm not sure if there is a cleaner way to do it, but 
> I found that subclassing your panel and then adding a property to keep a 
> reference to the controller worked. Like this:


You don't need to do this, it violates MVC.

Just loop through the controllers and remove the one that is controlling the 
window:

- (void)windowWillClose:(NSNotification *)aNotification
{
        NSWindow *panel = [aNotification object];
        NSWindowController* controllerToRemove = nil;
        for(NSWindowController* currentCntl in controllers)
        {
                if([[currentCntl window] isEqual:panel])
                {
                        controllerToRemove = currentCntl;
                        break;
                } 
        }
        [controllers removeObject:controllerToRemove];
}

--
Rob Keniger



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to