Problem with an NSWindowController's retain count
Problem with an NSWindowController's retain count
- Subject: Problem with an NSWindowController's retain count
- From: Ben Kazez <email@hidden>
- Date: Tue, 19 Jul 2005 15:23:29 -0400
My app delegate has an IBAction for creating and displaying an
instance of the main viewer window. The problem is that the window
shows up for a very brief time and then disappears, unless I don't
release the instance after adding it to my app delegate's array of
viewer windows.
Here's my -[WSAppDelegate createViewerWindow:] method:
- (IBAction)createViewerWindow:sender {
WSViewerWindowController *windowController =
[[WSViewerWindowController alloc]
initWithWindowNibName:WSViewerWindowNibName];
[self insertObject:windowController
inViewerWindowControllersAtIndex:0];
[windowController showWindow:self];
[windowController release];
}
Commenting out the [windowController release] line fixes the problem,
but I don't think this is a good solution.
WSViewerWindowController's initWithWindow and dealloc methods just
call the superclass's methods and don't do anything else.
Here's my -[WSAppDelegate insertObject:] method:
- (void)insertObject:(WSViewerWindowController *)
viewerWindowController inViewerWindowControllersAtIndex:(unsigned int)
index {
[[self viewerWindowControllers]
insertObject:viewerWindowController atIndex:index];
}
Here's my -[WSAppDelegate viewerWindowControllers] method:
- (NSMutableArray *)viewerWindowControllers {
if (viewerWindowControllers == nil) {
viewerWindowControllers = [[NSMutableArray alloc] init];
}
return [viewerWindowControllers autorelease];
}
What am I doing wrong? I'm sure it's something basic and simple.
Thanks for your help.
Ben
--
Ben Kazez
http://www.benkazez.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden