• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Multiple windows/window controllers, one document and Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: scrolling and drawing porblems
  • Next by Date: Re: scrolling and drawing porblems
  • Previous by thread: NSFetchRequest/NSPredicate behavior for different stores
  • Next by thread: Getting current user short name
  • Index(es):
    • Date
    • Thread