• 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: how to release my window controller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to release my window controller


  • Subject: Re: how to release my window controller
  • From: Chris Hanson <email@hidden>
  • Date: Sat, 02 Aug 2008 13:42:20 -0700

On Aug 2, 2008, at 8:23 AM, Torsten Curdt wrote:

Let's say in my AppController a new Non-modal window is getting opened like this

-  (IBAction) buttonOpen:(id)sender
{
	MyWindowController *controller = [[MyWindowController alloc] init];
	[controller showWindow:self];
}

Of course I will have to release the controller at some stage.

Since you've mentioned that this is a shared non-modal panel of some sort, you might want to consider making it a singleton controller. (I generally don't advocate "enforced" singletons in Cocoa -- overriding - retain, -release and so on -- just always going through a sharedWhatever class method.)


Then your method above just becomes something like this:

- (IBAction)orderFrontSomethingPanel:(id)sender { // renamed for Cocoa conventions
[[SomethingPanelController sharedSomethingPanelController] showWindow:self];
}


Since the shared panel is a global, you don't have to worry about releasing it or whether it's considered a leak (it should be recognized as a global and not considered one).

If the panel needs to be "reset" between uses, you can make the window controller a delegate of the window and reset its state when the window will close. This way, you can work with the window controller as you would any other in Cocoa, and it will handle the special behavior it needs itself.

  -- Chris

_______________________________________________

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: 
 >how to release my window controller (From: Torsten Curdt <email@hidden>)

  • Prev by Date: Re: Launch Path Not Accessible
  • Next by Date: Re: Some crash.
  • Previous by thread: Re: how to release my window controller
  • Next by thread: Coding around a known bug
  • Index(es):
    • Date
    • Thread