iCloud Key-Value Store with NSUbiquitousKeyValueStore

iCloud Key-Value Store with NSUbiquitousKeyValueStore

Ubi–what!? With the NSUbiquitousKeyValueStore you can sync key-value store data across iOS and Mac devices, via iCloud. It’s perfect for persisting user preferences to iCloud, and it’s simple to set up.

[…]

To use NSUbiquitousKeyValueStore, you’ll need to distribute your app through the iOS or Mac App Store. You must also set the com.apple.developer.ubiquity-kvstore-identifier entitlement in your app’s Entitlements. You can find your app’s entitlements in Xcode, by going to Project Settings -> Capabilities. Enable the iCloud capability and check Key-value storage. You might need to enable iCloud for your App ID too, by going to Certificates, Identifiers & Profiles on developer.apple.com/account.

[…]

The data in the key-value store is persisted between app installs – so it’ll be there even if you uninstall the app – and it’s synced between devices. You can even share the data store between iOS and Mac apps that have the same identifier.

[…]

That’s all there is to it! Reading and writing data with the iCloud data store is surprisingly simple. The NSUbiquitousKeyValueStore is ideal for syncing key-value store data between iOS devices – and now you know exactly how it works.

[…]