ios - Core Data: copy-on-write entities? -


we need ship large seed data in ios application bundle. application needs update data server required. updates server needs "overwrite" seed data required.

the plan have 2 persistent stores, "a" , "b", in "a" read-only persistent store mounted within application bundle , "b" read-write persistent store. need both stores share same model (and entities) keep application logic simple. hence if entity if modified , in store "a", modifications should saved in store "b" overrides attributes present in "a". in essence it's "copy-on-write" paradigm.

questions are:

  • is achievable in core data? how?
  • if not workable other alternatives having large seed data , yet not duplicating (a.k.a. wasting) space on user's device?

save new data:

store *newstoreitem = [nsentitydescription insertnewobjectforentityforname:@"store"                                                                         inmanagedobjectcontext:self.managedobjectcontext];                  newstoreitem.store_id       = [[data objectatindex:i] valueforkey:@"id"];                 newstoreitem.lat            = [[data objectatindex:i] valueforkey:@"lat"];                 newstoreitem.lng            = [[data objectatindex:i] valueforkey:@"lng"]; 

then when need, check it:

- (bool) isstoreexist {     appdelegate* appdelegate = [uiapplication sharedapplication].delegate;     self.managedobjectcontext = appdelegate.managedobjectcontext;          fetchedstoreitem = [[appdelegate getstore_byid:store_id]mutablecopy];       if ([fetchedstoreitem count] == 0)     {         return no;}     else     {         return yes;} } 

then replace data:

fetchedstoreitem = [[appdelegate getstore_byid:store_id]mutablecopy];                   store *oldstoreitem = [fetchedstoreitem objectatindex:0];                   oldstoreitem.store_id       = [[data objectatindex:i] valueforkey:@"id"];                  oldstoreitem.lat            = [[data objectatindex:i] valueforkey:@"lat"];                  oldstoreitem.lng            = [[data objectatindex:i] valueforkey:@"lng"]; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -