How to save data in iOS

后端 未结 6 967
有刺的猬
有刺的猬 2020-12-03 01:40

I\'m making a game and when I close the app (close at multitask manager), all my data is gone! So, My question is very simple: How do I save the data?

6条回答
  •  星月不相逢
    2020-12-03 02:05

    [NSUserDefaults standardUserDefaults] is good for small amounts of data like user settings and preferences. Typically you use this to enable users to save various bits of data that define global values such as character preferences, weapons preferences, whatever, etc.

    For larger amounts of data like game level details or achievements or weapons inventory, etc. You will want to use something like Core Data. This is a more formal database that can be easily migrated as your data schema changes. See the docs here: Core Data and Core Data Programming Guide

提交回复
热议问题