Should I use NSUserDefaults or a plist to store data?

后端 未结 9 1447
北海茫月
北海茫月 2020-11-28 19:17

I will be storing a few strings (maybe 10-20). I am not sure if I should use NSUserDefaults to save them, or write them out to a plist. What is considered best practice? NSU

9条回答
  •  生来不讨喜
    2020-11-28 20:01

    It depends on what you want to store and why. NSUserDefaults is meant for storing user preferences. You can try to use it for other things, but you probably shouldn't.

    Otherwise, if your needs are simple a plist file is pretty straightforward. You can also use core data or come up with your own file format. In general, I use plist for simple tasks and then move to core data for anything more complex.

提交回复
热议问题