Preamble: I am using RestKit 0.21.0, but I also tried 0.23.0.
I have several mappings in which the plain old Objective-C object (let it call POOCO) contains NSManagedObject . It appears that when executing GET requests on this root POOCO, the managed entity is created under mainQueueManagedObjectContext .
However, when I do PUT against POOCO, when the response is loaded (the response is a copy of the sent object), a managed sub-object is created under the temporary NSManagedObjectContext , the parent of which is mainQueueManagedObjectContext .
Quick switch to re-fetch in RestKit:
If the request consisted entirely of NSManagedObject instances, the resulting objects would be βreturnedβ using (I think) mainQueueManagedObjectContext . (IIRC, once all object matching has been completed, the objects and sub-objects will be re-mapped from the main MOC, replacing the objects created on the temporary MOC used for matching.)
This repetition is performed (as far as I can tell), because when the MOC receives dealloc , all the managed objects it manages become invalid . Thus, we return the objects to the MOC to which myObjectManager.managedObjectStore maintains a strong reference so that they remained valid after the interim MOC leaves.
Since the root object in the mapping is POOCO, any links that it has to managed objects are not re-received, so they remain attached to the temporary MOC and become invalid after the mapping is completed.
Does anyone else encounter such problems? Are there any recommendations you can offer? Can I tell RestKit, "restore these managed objects using mainQueueManagedObjectContext " or something like that?
ios objective-c cocoa core-data restkit
jsadler
source share