NSManagedObject How To Reload

Posted by crissag on Stack Overflow See other posts from Stack Overflow or by crissag
Published on 2010-06-02T21:29:47Z Indexed on 2010/06/02 21:34 UTC
Read the original article Hit count: 179

Filed under:

I have a view that consists of a table of existing objects and an Add button, which allows the user to create a new object. When the user presses Add, the object is created in the list view controller, so that the object will be part of that managed object context (via the NSEntityDescription insertNewObjectForEntityForName: method).

The Add view has a property for the managed object. In the list view controller, I create an Add view controller, set the property to the managed object I created, and then push the Add view on to the navigation stack.

In the Add view, I have two buttons for save and cancel. In the save, I save the managed object and pass the managed object back to the list view controller via a delegate method. If the user cancels, then I delete the object and pass nil back to the list view controller.

The complication I am having in the add view is related to a UIImagePickerController. In the Add view, I have a button which allows the user to take a photo of the object (or use an existing photo from the photo library). However, the process of transferring to the UIImagePickerController and having the user use the camera, is resulting in a didReceiveMemoryWarning in the add view controller.

Further, the view was unloaded, which also caused my NSManagedObject to get clobbered. My question is, how to you go about reloading the NSManagedObject in the case where it was released because of the low memory situation?

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0