SquidInSuperMario
SquidInSuperMario

Reputation: 43

Data persistence in an iOS-Swift app

I am creating a fairly simple game in Swift and I am unsure of which data persistence method would be best suited for the project. This is my first "real" project so please excuse my ignorance.

I have to be able to store the following data for users:
- On/Off states for game sound
- The users' high-score
- A game currency unit that users may purchase In-App
- An indicator of whether Ads are enabled or disabled in the game

Also the user has to be able to restore all data from iCloud (I know that's a whole separate issue). Can I accomplish this with just NSUserDefaults/plists or is this more up the alley of Core Data?

Upvotes: 1

Views: 539

Answers (2)

Jason Nam
Jason Nam

Reputation: 2011

There is NSUserDefaults. Yes you can save those small settings.

There is also iOS keychain to store the sensitive data like amount of currency but I don't think it is that important to keep it in the keychain. If you are interested in the keychain check out this repository.

Locksmith

Finally if you try to save the settings in the iCloud you can use the iCloud key value storage.

iCloud Preference storage

Upvotes: 0

Glenn
Glenn

Reputation: 2806

NSUserDefaults is great for storing very small amounts of data. In your case this may be a good choice.

Upvotes: 1

Related Questions