• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with multiple instances of a nib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Problem with multiple instances of a nib (From: PCWiz <email@hidden>)
 >Re: Problem with multiple instances of a nib (From: Ben Haller <email@hidden>)
 >Re: Problem with multiple instances of a nib (From: PCWiz <email@hidden>)
 >Re: Problem with multiple instances of a nib (From: Rob Keniger <email@hidden>)
 >Re: Problem with multiple instances of a nib (From: PCWiz <email@hidden>)

  • Prev by Date: Re: Problem with multiple instances of a nib
  • Next by Date: NSTreeController content array bindings
  • Previous by thread: Re: Problem with multiple instances of a nib
  • Next by thread: Re: Problem with multiple instances of a nib
  • Index(es):
    • Date
    • Thread