NSManagedObjectContext becoming nil for unsaved ManagedObject
I an working on a data entry screen, where one of the fields is selected from a list of existing objects. On the main screen, I create a new instance of a managed object within my ManagedObjectContext, but don't save until the user is done with the changes. To implement the selection list, I open a new window with a table, passing in the uncommitted manged object. When the new window opens, I can get the ManagedObjectContext from the passed in object to select the items for the list. Yet, when I go to update the user selections, I get an error, because the ManagedObjectContext has become nil. I can't understand why this has happened.
I am working from the CoreDataRecipes example, and the only difference I can find is that the object I am creating has never been commited - it only resided in the ManagedObjectContext.
I have made some modi开发者_如何学运维fications, whereby I save the managedObjectContext before opening the selection window and things work as expected.
Why am I losing my reference to the managedObjectContext for an uncommited object?
What am I doing wrong?
精彩评论