简体   繁体   中英

How to store small to medium sets of data in iOS (for easy iCloud-sync)?

I have an iOS application that currently manages a small bunch of settings (via NSUserDefaults, I know how to sync these via iCloud) and some list data.

Let's say as an example I want to store a list of <color name / color / comment>. So I create a custom type, that is called ColorInfo. In my app I need to store multiple values of ColorInfo, I'd try and achieve that using an NSMutableArray or a database, but both are not easily synchronizable via the iCloud.

What ways to manage lists of data do you prefer in your iOS apps to meet the following two requirements?

  1. You should be able to easily store the data persistently on the local phone.
  2. You should be able to easily sync the data via the iCloud.

You want to use UIDocument its designed for local archiving and iCloud persistence.

Developer Doc

Do not use the key value storage. It is very.. weird.

I would make my own version of the key value storage by creating a local file and a remote file of the same name. To sync, you have to download the remote file and combine its contents with the local data. Write it to the file and upload the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM