NSDocumentController redisplay NSPanel
NSDocumentController redisplay NSPanel
- Subject: NSDocumentController redisplay NSPanel
- From: Chris Outwin <email@hidden>
- Date: Thu, 10 Feb 2005 16:36:08 -0600
I am trying to hide and then redisplay a NSPanel contained in a nib. The panel is lazily allocated via the main menu and displays properly. However after the user closes the one and only panel instance, the document is removed from the document controller. (The panel is owned by a NSWindowController subclass which reports NO to isReleasedWhenClosed in makeWindowControllers.)
The action method is an if/else which allocates the custom NSDocument if the document is nil and redisplays the panel otherwise.
NSDocument* myDocument // In class interface
- (id)sender {
NSDocumentController* dc = [NSDocumentController sharedDocumentController];
if(!myDocument) {
myDocument =[[dc openUntitledDocumentOfType:@"myDocument" display:YES]retain];
}
else {
[myDocument showWindows];
//NSLog now reports zero controllers.
NSLog(@"Upon redisplay of nib, there are %u controllers", [[selfwindowControllers]count]);
}
}
I thought of trying NSWindow's - setReleaseWhenClose, but the docs say it's ignored for windows owned by a controller. But clicking the panel's close button seems to remove the document from the document controller. So the document has been removed from the controller then the above else clause is reached.
How do you retain the panel for redisplay and still have the document controller deallocate the panel when the app closes?
_______________________________________________
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