Should I use NSUserDefaults or a plist to store data?

后端 未结 9 1423
北海茫月
北海茫月 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:00

    iOS ultimately stores all NSUserDefaults data to a plist file. So it will not affect the performance if that is your concern. I personally prefer using NSUserDefaults for small data and plist for a relatively large set of data.

    Note: Never store any sensitive information in NSUserDefaults as anyone can see that data.

提交回复
热议问题