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 (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 [EMAIL PROTECTED]

Reply via email to