iphonedatabasecocos2d-iphoneplistnsuserdefaults

Where should I save gold/exp attributes of my cocos2d Iphone Game?


I'd like to save my gold and experience attributes so that they can be retrieved whenever the app launches.

I don't know whether I should use .plists or NSUserdefaults. What's the difference? Can I somewhere manually edit the NSUserdefaults outside of the code like I can do it with plists? The problem is, I don't want the user to loose all his gold/exp for any reason.

Gold and exp are both integer values. Do you think NSUserdefaults would be the right choice?


Solution

  • NSUserDefaults are retained during an upgrade. It is easy to use to (a one-liner to save/restore settings).

    They are not available to anyone who could tamper with them - unless they jailbroke the phone, then I suppose people could get at them no matter what method you use.

    If you are totally paranoid about that scenario, you could encrypt/decrypt the data during save/restore, but that's probably overkill.