简体   繁体   中英

How do you store data remotely in an iOS app?

I have an app that relies on some key value pairs where the value could change at a point in the future due to 3rd party api. The app is only useful when connected to the internet by the way. If any values change I don't want issue a new version of the app - I would rather that these values were pulled from a webservice/static xml file on my server. I would only need to pull these if I encountered an error.

Is there a standard way to do this or should I just roll my own?

EDIT: I'm not so interested in a server side technology - I think a flat file will suffice. What I'm interested in is what format should the flat file should be and how to cache it into my application once I get an error.

try redis, high-performance key-value store. used by some of the big cloud players, like cloudfoundry. Have a look at http://redis.io/ . Objective-c client is available at http://redis.io/clients .

I figured out the best way for my use scenario:

I setup a json file on S3 which required authentication. I then used AWS for Objective C to authenticate so I could access that file.

I decided that I only needed to update the local info when the applicationDidBecomeActive in the App Delegate. I then got the json async and on success I then checked a version number in the json and if outdated wrote the changes to NSUSerDefaults (which are then used through the app.) If there was an error getting the json file I just continued as I would already have the previous set of NSUserDefaults that would do the job until the user next made the app active.

This solution worked best for me as it's simple to maintain and should easily handle the load even if my app were popular.

Have you considered using iCloud? It has support for key value pairs. More info here: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/iCloud/iCloud.html

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