Search code examples
core-dataicloud

Uniqueness of NSPersistentStoreUbiquitousContentNameKey for iCloud and Core Data


In my app which allows users to sync the core data content across their multiple devices, how unique should I make the NSPersistentStoreUbiquitousContentNameKey?

I.e. should it be unique in the sense of having the device ID? So if a user is running an app on their iPhone it has one NSPersistentStoreUbiquitousContentNameKey and if they're running it on their iPad is has another NSPersistentStoreUbiquitousContentNameKey?

Or does it have just be unique from app to app? I.e. if I have App A, it has one NSPersistentStoreUbiquitousContentNameKey and App B has another NSPersistentStoreUbiquitousContentNameKey?


Solution

  • It's purpose is to uniquely identify the persistent store within a users account. So if an app will only ever have a single persistent store (like a todo list might) then every installation of that app can share the same value for this key, but if you want to have multiple persistent stores then each one will need a unique key value here. Does this help?