0

I need to sync my program's .plist to iCloud, both to update a tableView and to store in the cloud. How do I go about doing this? All the tutorials I have been looking at seem either outdated or confusing. Is there any simple way of going about this?

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170
  • What is confusing? What code did you try? – Black Frog May 12 '14 at 03:14
  • tried the MKiCloudSync, but that seemed to be outdated. I really don't know where to start besides enabling iCloud under the capabilities part of the program. – user3430084 May 12 '14 at 03:16
  • 3
    *"...the core data of my program's .plist..."* is not a phrase that makes sense in the context of iOS development. Are you trying to sync a plist, or Core Data, or both, or something else maybe? – Tom Harrington May 12 '14 at 04:05
  • possible duplicate of [Can I use iCloud to sync the NSUserDefaults plist file](http://stackoverflow.com/questions/7810157/can-i-use-icloud-to-sync-the-nsuserdefaults-plist-file) – Caleb May 12 '14 at 04:32
  • I'm trying to sync my nsuserdefaults plush. Caleb that one seems to be outdated – user3430084 May 12 '14 at 12:36

1 Answers1

1

From Apple iCloud Design Guide,

iCloud supports three kinds of storage. To pick the right one (or combination) for your app, make sure you understand the intent and capabilities of each. The three kinds of iCloud storage are:

  • Key-value storage for discrete values, such as preferences, settings, and simple app state.
  • Document storage for user-visible file-based information such as word processing documents, drawings, and complex app state.
  • Core Data storage for shoebox-style apps and server-based, multi-device database solutions for structured content. iCloud Core Data storage is built on document storage and employs the same iCloud APIs.

Therefore, you don't sync NSUserDefaults (plist) to iCloud; you would start using the NSUbiquitousKeyValueStore object instead.

From Designing for Key-Value Data in iCloud:

As you do with an NSUserDefaults object, use the iCloud key-value store to save and retrieve scalar values (such as BOOL) and property-list object types: NSNumber, NSString, NSDate, NSData, NSArray, and NSDictionary. Array and dictionary values can hold any of these value types.

The NSUbiquitousKeyValueStore class provides methods for reading and writing each of these types, as described in NSUbiquitousKeyValueStore Class Reference.

Black Frog
  • 11,595
  • 1
  • 35
  • 66
  • Hey @Black Frog, is it possible to store a .plist file as a Document in iCloud though? key-value storage has its limitations and Apple already provides a Plist Decoder that could be used. Apple's own documentation does say that iCloud Document storage is intended for complex app states, which is what I need a solution for. – CristianMoisei Jul 02 '19 at 22:19