Hey guys,

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. Now there are a couple of ways doing this:

1. Inside the window controller call [self close]; [self release];

Not really sure this would actually be OK as the release could happen to soon.

2. Inside the window controller [self close]; [self autorelease];

This would delay the release of the controller.

But with both methods the AppController class does not have any idea the window got closed (and released). Which can be a problem if you want to act on this event. So there is another option:

3. Create a showWindow: andCallOnClose: and pass in a selector and then call the selctor on close

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

- (void) windowClosed:(id)controller
{
        [controller release];
}

But I wouldn't be surprised if there was an easier way of doing this. Is there?

cheers
--
Torsten
_______________________________________________

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