ios5 - Core Data: move object from one persistent store to another -


i'm using core data in app , export of data , import on other device.

to avoid migration issues, i'd following:

export:

  • create second export.sqlite-file same database model, empty
  • add file addpersistentstorewithtype
  • copy managedobjects on .sqlite
  • remove added persistent store

import: - copy export.sqlite-file app - add .sqlite-file addpersistentstorewithtype - copy data on - remove added persistentstore

but how achieve that? i.e. how can tell managed object copy other store?

how can tell managed object copy other store?

you can't, not directly anyway. you'll have like:

  • for each object in origin data store,
    • create new object in target store same entity type
    • assign new object's attributes same values original object
  • once you're done creating new objects, second pass set relationships.

the relationships need done separately, because of objects in relationship need exist before can create relationship.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -