• 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
Problem binding to MOC from a separate nib, solved but not satisfactorily
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem binding to MOC from a separate nib, solved but not satisfactorily


  • Subject: Problem binding to MOC from a separate nib, solved but not satisfactorily
  • From: George Orthwein <email@hidden>
  • Date: Mon, 19 Jun 2006 15:13:07 -0400

I have occasionally been getting the following error randomly. Usually at startup but sometimes later on...

*** NSRunLoop ignoring exception 'Cannot perform operation without a managed object context' that raised during posting of delayed perform with target 532bb20 and selector 'invokeWithTarget:'

The standard search results say make sure your controllers are bound to a moc. They all are. However, the NSArrayControllers in my second nib are bound to the MOC with:
SharedApp->mainWindow.windowController.document.managedObjectContext


Standard inspector setup, right?

I started to suspect that perhaps mainWindow wasn't valid sometimes. If I hit "Run" in Xcode and then clicked the desktop to put my app in the background, I started getting the error on startup every time.

To solve it, I removed the MOC binding for the controller in the second nib, and instead bound the "contentArray" to arrangedObjects of a similar NSArrayController in my main nib:
mainWindow.windowController.document.backgroundImageController.arrangedO bjects


The errors are gone, but I'm not very confident in my solution. Partly because it involved creating an "extra" NSArrayController in the main nib I didn't even need before. (and I'm still referencing mainWindow... so maybe it being valid isn't the problem...)

The docs on mainWindow say:
This method returns nil if there is no main window, if the application’s nib file hasn’t finished loading, if the receiver is not active, or if the application is hidden.
The errors occurred after windowControllerDidLoadNib, but perhaps NSApp is not yet "active". Maybe I need to check if mainWindow exists and then do a fetch on the array controllers manually?

Could my Inspector panel be interfering?

Is there a better way to reference the current document's moc from a second nib?

I suspect I'm doing something "weird" since I'm not seeing this mentioned in the archives. :(

Thanks all,
George _______________________________________________
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: Stopping an NSRunLoop OR getting NSDistributedNotificationCenter notifications
  • Next by Date: Re: NSWindow's setContentView
  • Previous by thread: Re: Stopping an NSRunLoop OR getting NSDistributedNotificationCenter notifications
  • Next by thread: Getting average power / peak power (sound monitoring)
  • Index(es):
    • Date
    • Thread