how to release my window controller
how to release my window controller
- Subject: how to release my window controller
- From: Torsten Curdt <email@hidden>
- Date: Sat, 2 Aug 2008 17:23:08 +0200
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 (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