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: Keary Suska <email@hidden>
- Date: Fri, 21 May 2010 09:26:19 -0600
On May 21, 2010, at 12:09 AM, Quincey Morris wrote:
> 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.
This specific issue is unlikely the case, as NSWindowController lazily loads its nib--i.e. not until something asks for the window object. The nib would not be loaded on initialization, unless subclassed to specifically do so.
Anyway, Steve, if you want useful answers, you must give specific information using specific language.
>> However, I'm using CoreData and I want to pass the existing MOC to the pref window:
>> I have added an array controller to the pref nib with its MOC set to files owner's MOC in IB.
How did you set the MOC? Using bindings or outlet? If you used outlet, I am sorry to say, that is very wrong.
In any case, you are being told the problem--your MOC is not being properly set. Debug appropriately.
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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