Problem binding to MOC from a separate nib, solved but not satisfactorily
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