• 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
Re: NSWindowController for Prefs XIB Question (Core Data involved)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSWindowController for Prefs XIB Question (Core Data involved)
      • From: Keary Suska <email@hidden>
References: 
 >NSWindowController for Prefs XIB Question (Core Data involved) (From: Steve Cronin <email@hidden>)

  • Prev by Date: Re: Notifications on main thread
  • Next by Date: Re: NSWindowController for Prefs XIB Question (Core Data involved)
  • Previous by thread: NSWindowController for Prefs XIB Question (Core Data involved)
  • Next by thread: Re: NSWindowController for Prefs XIB Question (Core Data involved)
  • Index(es):
    • Date
    • Thread