简体   繁体   English

在iOS中保持应用程序配置:.plist文件与NSUserDefaults

[英]Persisting app configuration in iOS: .plist file vs NSUserDefaults

I have some app-related parameters (boolean and string data) which are either set by user through the app, either at its first execution. 我有一些与应用程序相关的参数(布尔值和字符串数据),这些参数是由用户在首次执行时通过应用程序设置的。 I don't want this kind of information to be stored by using Core Data , so the options I'm thinking about are: 我不希望使用Core Data来存储这种信息,所以我正在考虑的选项是:

1) Creating and reading/writing a custom .plist file (let's say, myconfig.plist ) to be stored in Documents app folder 1)创建和读取/写入要存储在Documents应用程序文件夹中的自定义.plist文件(例如myconfig.plist

2) Saving such info using NSUserDefaults 2)使用NSUserDefaults保存此类信息

The kind of information I want to keep is, for example, the last app version that was installed and run in order to check if app is being updated, or a flag telling if some specific set of data has been already loaded without having to check the model. 我想要保留的信息类型是,例如,为了检查应用程序是否正在更新而安装并运行的最后一个应用程序版本,或者一个标志,用于指示是否已经加载了某些特定的数据集而无需检查该模型。

Which of the options would be the most suitable and safest for this task? 哪个选项最适合此任务且最安全? Or is even there any better option of handling this? 还是有更好的选择来处理这个问题?

Thanks 谢谢

如果您要使用实际的应用程序版本检查应用程序商店版本,请尝试此操作https://github.com/nicklockwood/iVersion

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM