简体   繁体   English

NSUserDefaults用于功能数据

[英]NSUserDefaults for functional data

I'd like to add functional data in the NSUserDefaults object but I'm a little bit embarrassed as for me this object is more for application settings than for functional stuff. 我想在NSUserDefaults对象中添加功能数据,但让我有些尴尬的是,对于我来说,该对象更多是用于应用程序设置,而不是功能对象。
Does it make sense to use NSUserDefaults for this purpose ? 为此目的使用NSUserDefaults是否有意义?

A NSUserDefaults is a plist with features designed to store user preferences. NSUserDefaults是具有旨在存储用户首选项的功能的plist。 It's often used instead a regular plist to save a couple of lines of code, which I think it's a bad idea because you get an additional complexity unrelated to your task, but it's unlikely to cause trouble. 它通常代替常规的plist来保存几行代码,我认为这是一个坏主意,因为您会获得与您的任务无关的其他复杂性,但不太可能引起麻烦。 If it eases your mind learn to read/write a regular plist. 如果您感到轻松,请学习阅读/编写常规plist。 It's easy. 这很容易。 Using the NSKeyedArchiver/NSKeyedUnarchiver to serialize graphs of objects is another way to read/write plists that it's worth the time learning. 使用NSKeyedArchiver / NSKeyedUnarchiver序列化对象图是另一种读取/写入plists的方法,值得学习。

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

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