Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 825
Choppin Broccoli Avatar asked Nov 11 '13 01:11

Choppin Broccoli


People also ask

What is Core Data a feature of?

Core Data is a framework developed and maintained by Apple. It's been around for more than a decade and first made its appearance on macOS with the release of Mac OS X Tiger in 2005. In 2009, the company made the framework available on iOS with the release of iPhone OS 3.

Why should I use Core Data?

Use Core Data to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device. To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.

What is CloudKit Core Data?

Core Data owns the record ID for all of the objects that it creates in CloudKit. And, for each one, we will generate a simple UUID to use as its record name. When the Record Name is combined with a zone identifier you get a CKRecord ID. At the bottom, you'll see how Core Data manages type information.

Should I use Core Data iOS?

The next time you need to store data, you should have a better idea of your options. Core Data is unnecessary for random pieces of unrelated data, but it's a perfect fit for a large, relational data set. The defaults system is ideal for small, random pieces of unrelated data, such as settings or the user's preferences.


1 Answers

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?

like image 156
dtrotzjr Avatar answered Oct 19 '22 09:10

dtrotzjr