small medium large xlarge

Back to: All Forums  Core Data
Generic-user-small
09 Apr 2009, 19:12
Greg Robertson (21 posts)

Any chance of a recipe for how to transfer data from one store to another. In particular how to move an instance of an object that has a to-many relationship to another entity’s objects where there is no relationship between the two stores.

ie if Store A has 2 entities: Entity Persons and the attribute ‘name’ and Entity Instruments has an attribute ‘name’ and there is a one to many relationship between Persons and Instruments and Store B has an identical 2 entity setup as Store A but different data.

How can for example I move all data from Store A to Store B where Person.name = “John Smith”?

Do I need to loop through each object found in a request to Store A and insert in Store B or is there a quicker way. In particular I am not sure how to handle the to-many relationship data.

If the code is fairly simple could you please post or if the code is more complicated can you provide a link for a similar example I could study? I would of course love to see this in your book.

A more complicated version of this which I hope to implement is an iPhone SDK Peer-to-Peer transfer of the data between stores which would be cool in your book but probably beyond its scope.

Thanks

Greg

Avatarsmall_pragsmall
10 Apr 2009, 15:41
Marcus S. Zarra (284 posts)

If you look at the data import and export section in the Multi-threading chapter, it copies entities from one persistent store to another. Core Data handles this quite smoothly and you can take the concept and apply it to some future release of the iPhone ;-)

You must be logged in to comment