Home ios-icloud
Post
Cancel

ios-icloud

Designing for Key-Value Data in iCloud

iCloud Design Guide.

class NSUbiquitousKeyValueStore

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
An iCloud-based container of key-value pairs you use to share data among instances of your app running on a user's connected devices.

Use the iCloud key-value store to make preference, configuration, and app-state data available to every instance of your app on every device connected to a user’s iCloud account.

You can store scalar values such as BOOL, as well as values containing any of the property list object types: NSNumber, NSString, NSDate, NSData, NSArray, and NSDictionary.

Changes your app writes to the key-value store object are initially held in memory, then written to disk by the system at appropriate times. If you write to the key-value store object when the user is not signed into an iCloud account, the data is stored locally until the next synchronization opportunity.

When the user signs into an iCloud account, the system automatically reconciles your local, on-disk keys and values with those on the iCloud server.

Any device running your app, and attached to the same iCloud account, can upload key-value changes to iCloud. 

To keep track of such changes, register for the didChangeExternallyNotification notification during app launch.Then, obtain the keys and values from iCloud (which may be newer than those that are local) by calling the synchronize() method. 

You need not call the synchronize() method again during your app’s life cycle, unless your app design requires fast-as-possible upload to iCloud after you change a value.
This post is licensed under CC BY 4.0 by the author.