user1019611
user1019611

Reputation:

Where to save state in an iPhone app

I'm wondering the proper place to save the running state of an app now that iCloud and iOS5 have changed how the various options work.

NSUserDefaults? I always had the impression this was for settings. Is it okay for state as well?

The app's NSDocumentDirectory? Isn't that synced with iCloud? I have no particular desire to upload the state of the app. It's unnecessary.

Caches? That's now purged occassionally. It's not a secure spot to save things.

So what's the official, recommended place to save state these days?

Upvotes: 7

Views: 593

Answers (1)

Clafou
Clafou

Reputation: 15400

It looks to me like iOS developers tend to use NSUserDefaults even though it's meant for user settings as you point out.

For example I recently added the popular Appirater library to my app and discovered that it uses NSUserDefaults to store its state (such as how many times the app was launched).

Upvotes: 4

Related Questions