0
votes

For an iOS application using MagicalRecord to communicate with core data backed sqlite database, what should be the approach for saving large json data through web service calls ?

Since MagicalRecord (MR) has an NSManagedObjectContext called 'rootContext' with NSPrivateQueueConcurrencyType concurrency type which is associated with persistent store as topmost context. Then comes another NSManagedObjectContext called 'defaultContext' with a NSMainQueueConcurrencyType type [seemingly used for dealing with core data on main thread]. This 'default context' has a parent NSManagedObjectContext as 'root context'.

My question is for a large background running downloading of json data [comprising of multiple core data entities] that needs to be persisted to sqlite, should we create a single context with NSPrivateQueueConcurrencyType whose parent is rootContext or multiple contexts ?

What approach one should use, any idea?

1

1 Answers

0
votes

That depends on what the data is really - I.e. Are there relationships between the data or not, which dictates if multiple sections of the data can be loaded concurrently. You only need one context and one background thread, but you can use more if the data allows and it improves performance (which you will need to test and profile). Having lots of contexts is unlikely to help much (or actually just make things slower).