Multiple windows/window controllers, one document and Core Data
Multiple windows/window controllers, one document and Core Data
- Subject: Multiple windows/window controllers, one document and Core Data
- From: Andrew Roche <email@hidden>
- Date: Tue, 7 Nov 2006 21:16:30 +0000
I have an NSPersistent subclass with one main window with an
NSWindowController subclass and I am adding it to the document thus:
-(void)makeWindowControllers
{
MainWindowController *mainWindowController =
[[MainWindowController alloc] init];
[self addWindowController:mainWindowController];
[mainWindowController setShouldCloseDocument:YES];
[mainWindowController release];
mainWindowController = nil;
} // makeWindowControllers
I have a second window with its own NSWindowController subclass which
I want to appear when the user chooses a menu item. So I have this
IBAction in my Document subclass:
-(IBAction)showTransactions:(id)sender
{
if (![self transactionsWindowController])
{
[self setTransactionsWindowController:
[[[TransactionsWindowController alloc] init] autorelease]];
[self addWindowController:[self transactionsWindowController]];
} // if
[[self transactionsWindowController] showWindow:self];
} // showTransactions:
The -init method of TransactionsWindowController loads the
appropriate nib file.
When the TransactionsWindowController is dealloc'ed I do;
[[self document] setTransactionsWindowController:nil];
[super dealloc];
The transaction window has an NSTableView with columns bound to an
NSArrayController which has its managedObjectContext bound to
document.managedObjectController all in the nib.
When I first show the window it works fine.
The problem is that if I close the transactions window and reopen it
the connection to the managedObjectContext is lost.
When I close the transactions window it does not dealloc.
It did work when I allowed the showTransactions IBAction to create
multiple transaction windows, but this is not what I want.
Be Melindrical!
_______________________________________________
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