简体   繁体   中英

RestKit Managed Object Context goes nil

Ok so I'm using RestKit and I have it working pretty well when it comes to the JSON + Rest part of things but implementing Core Data has been quite hair-raising.

In essence, I have a DaoManager singleton that holds an RKObjectManager. From within my Singleton:

  1. I load some objects via RestKit into CoreData and getting back valid NSManaged Objects with a valid ManagedObjectContext (each one).
  2. I save these objects into an instance array and then call an NSOperation on some non-managed objects.
  3. The NSOperation calls a callback method on my Singleton on the main thread and I am able to see my NSManaged objects are still available but from within them, the ManagedObjectContext is now nil/null.

How this affects me is that the second I try to modify any of the properties on these objects, I get a CoreData Exception and I believe it's because the MOC is now nil.

Note: THe RKObjectManager and RKObjectstore are still valid throughout this whole process.

Has anyone else run into this? The thing about the MOC that RestKit sets up is that it's not really visible. It's supposed to handle everything itself in that way.

Any help appreciated. Thanks!

Well I ended up scrapping RestKit + CoreData since I couldn't get this to work.

Instead, I continued using Restkit to map objects from JSON but then I used my own Core Data objects to save a few important attributes to a local data store (ie images).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM