I'm currently implementing persistentStoreEnsemble:globalIdentifiersForManagedObjects: delegate and have a difficulty to decide about what global identifier to provide.
My Core Data model has two entities: book and image.
For book objects, there is no issue, as I should probably return a UUID, which should be stored in a dedicated property of the book.
However, I'm not sure about the global identifier for an image. Note that the image and book entities have one-to-one relationship in the data model, with a 'cascade' delete rule, which means that once a book is deleted, the linked image is deleted as well. So an image cannot exist in the database without being linked to a book.
Based on the above description, I was wondering if should I return NSNull, UUID, or a hash code (calculated at runtime from the image data) as the global identifier for a given image object?
Thanks for any suggestion.
Just use a UUID, I would say. I guess the image is stored as external data on the entity, right? If that is the case, Ensembles will sync it up, and will automatically use a hash to ensure it is not uploaded twice if the image happens to be the same. So for your entity, just use a UUID like you would for the book entity.