Question

I would like to use the getObjectFromPath method from RestKit to get data from my server. My testing server only has 3 records. After calling getObjectFromPath I assign them to an NSMutableArray to display on a UITableView.

I followed the RKMagicalRecord config and setup Core data locally.

However, everytime I run the app in the simulator, the number of records in the sqlite database grows like this

Number of time execute addSQLitePersistentStoreAtPath : number of records in sqlite

  • 1st time execute addSQLitePersistentStoreAtPath : 0
  • 2nd time execute addSQLitePersistentStoreAtPath : 3
  • 3rd time execute addSQLitePersistentStoreAtPath : 6
  • 4th time execute addSQLitePersistentStoreAtPath : 9

I have never use any saving method from Magical Record. As I google around, the getObjectFromPath method will do a mapping and then call the success callback block. During the mapping, it will auto-save Core Data.

But I don't understand why it did not save before execute addSQLitePersistentStoreAtPath. How can I disable the auto save in RestKit after mapping ?

Was it helpful?

Solution

You can not disable the auto-save. If you don't want object saved into the Core Data store then use plain NSObject subclasses.

That said, you should use Core Data, and what you're missing is probably setting the unique identifier key on the mapping (identificationAttributes). If you don't have unique identifier information coming from the server then you should add it. See this example entity mapping with identificationAttributes.

Calling addSQLitePersistentStoreAtPath creates the store the first time it's called and loads it on subsequent calls. So, before you call it there is no store so nothing can be added to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top