Re: Problem with multiple instances of a nib
Re: Problem with multiple instances of a nib
- Subject: Re: Problem with multiple instances of a nib
- From: Rob Keniger <email@hidden>
- Date: Mon, 23 Nov 2009 12:27:42 +1000
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 (email@hidden)
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:
This email sent to email@hidden