I'm looking to serialize a collection of Core Data objects (probably into JSON) and have been doing reading on the subject. I'll likely be serializing/deserializing JSON data as a means of allowing iOS users to easily export and re-import their data. This could be a case of backing up and restoring on the same device, or importing the data onto an entirely new device.
My main question at this point is how I handle the identification of existing data during import. If I'm reimporting objects that already exist in the store I'd ideally like to update them. Likewise, I'd like to leave any existing data that's not included in the import alone. What's the best practice in this situation? Should I assign each NSManagedObject a unique ID as and when it's created and compare this ID when determining whether an object is equal?
I'm aware that each NSManagedObject has an objectID assigned to it, but I'm not entirely sure I can rely on this given that exported data could be imported onto an entirely separate device (where objectID's could well collide or, more likely, the object would be assigned a new objectID upon creation).