Choppin Broccoli
Choppin Broccoli

Reputation: 3076

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?

Upvotes: 6

Views: 932

Answers (2)

Basem Saadawy
Basem Saadawy

Reputation: 1818

From apple docs:

The content name is used to identify the store across different devices so that transactions are synced consistently with the potentially many instances of that persistent store file across all the devices. For this reason, you must make sure you provide a unique name for each store—for example, a UUID.

https://developer.apple.com/library/IOs/releasenotes/DataManagement/RN-iCloudCoreData/

Upvotes: 0

dtrotzjr
dtrotzjr

Reputation: 945

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?

Upvotes: 2

Related Questions