应用程序设置的 NSUser 默认值与应用程序委托
我目前将应用程序设置存储在名为“设置”的实体中。我的每一个设置都是一个属性。我有一个设置对象,我将其加载到我的应用程序委托中,并在整个项目中通过委托访问它。我正在考虑将设置移至 NSUser 默认值。我可能不需要设置捆绑包,因为我已经在应用程序中设置了所有内容。除了使用设置包之外,我想知道是否有人可以告诉我使用 NSUserDefaults 比我当前的方法有什么好处?我的选择是否可以影响/提高应用程序性能?
I currently have my app settings stored in an Entity called Settings. Each of my settings is an attribute. I have one Settings object which I load in my app delegate, and I access it through the delegate throughout the project. I am thinking of moving the settings to NSUser defaults. I would probably not need the Settings bundle since I have everything setup in the app. Besides the use of the settings bundle, I was wondering if anyone can tell me what are the benefits of using NSUserDefaults over my current method? Is there any way my choice can affect/improve app performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果需要保存大量项目,那么归档或像您当前拥有的 plist 可能是最好的选择。
NSUserDefaults 的优点之一是可以通过任何方法单独访问和保存特定项目。 NSUserDefaults 还支持几种非对象类型。
通常,如果我需要保存大部分类状态,我将使用归档。
没有理由不使用组合,单独选择每个项目的持久化方法。
一般不会有太大的性能差异。
对于大量数据,请选择核心数据。
If there are a substantial number of items to be saved then archiving or a plist such as you currently have may well be best.
One advantage of NSUserDefaults is that specific items can be accessed and saved from any method individually. NSUserDefaults also supports several non object types.
Typically if I need to save essentially most of a classes state I will use archiving.
There is no reason not to use a combination, choose the method of persistence of each item individually.
Generally there will not be a large performance difference.
For substantial data choose Core Data.