Re: How to completely release every object allocated when opening a NIB file ?
Re: How to completely release every object allocated when opening a NIB file ?
- Subject: Re: How to completely release every object allocated when opening a NIB file ?
- From: mmalcolm crawford <email@hidden>
- Date: Wed, 14 Jan 2004 00:27:03 -0800
On Jan 12, 2004, at 1:15 AM, Jirome Foucher wrote:
I'm having big problems stopping my application from leaking.
- Here's the short story :
My app loads differents NIB files using
[NSBundle loadNibFile:path externalNameTable:NULL
withZone:NSDefaultMallocZone()];
The NIB file only holds a NSWindow which is set to release when
closed. The owner is a NSWindowController.
It's not clear why you're using NSBundle to load the nib file in this
case (where the File's owner is an NSWindowController)?
I'd expect to see something more like:
- (IBAction)makeNewWindow:(id)sender
{
MyWindowController *wc = [[MyWindowController alloc] init];
[windowsArray addObject:wc];
[wc release];
[wc showWindow:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(wcWindowClosed:)
name:NSWindowWillCloseNotification
object:[wc window]];
}
- (void)wcWindowClosed:(NSNotification *)note
{
MyWindowController *wc = [[note object] delegate];
[windowsArray removeObject:wc];
}
(You'd override windowNibName in MyWindowController
- (NSString *)windowNibName
{
return @"MyWindow";
}
)
Then I don't think you should have problems?
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.