Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple windows/window controllers, one document and Core Data



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.