Re: NSWindowController for Prefs XIB Question (Core Data involved)
Re: NSWindowController for Prefs XIB Question (Core Data involved)
- Subject: Re: NSWindowController for Prefs XIB Question (Core Data involved)
- From: Quincey Morris <email@hidden>
- Date: Thu, 20 May 2010 23:09:22 -0700
On May 20, 2010, at 20:08, Steve Cronin wrote:
> if (!prefPanelController) {
> prefPanelController = [[PreferencesController alloc] initWithWindowNibName:@"testPref"];
> [prefPanelController setManagedObjectContext:[self managedObjectContext]];
> }
> [prefPanelController showWindow:sender];
>
> No window opens and I get a console error: Cannot perform operation without a managed object context
This could well be a time, or order of things happening, problem.
At the time the nib is loaded, the MOC property of the controller hasn't been set yet, so the array controller fetches a nil MOC, and throws an exception which aborts the rest of the loading process.
You probably need to write a custom initializer for your custom window controller and pass the MOC as a parameter, instead of trying to set it later.
That's my theory, anyway.
Note you can figure this out by writing your own getter method, setting a breakpoint in it and see if it's called while the MOC value is still nil. Also make sure you (always) have a breakpoint on objc_exception_throw, so that you see the backtrace of exceptions at the time they occur.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden