简体   繁体   English

Settings.bundle与NSUserDefaults

[英]Settings.bundle vs NSUserDefaults

I have my settings.bundle configured to show 4 settings, which I want user to access/change. 我将settings.bundle配置为显示4个设置,我希望用户可以访问/更改。 During application lifetime I have another couple of values, that i store in NSUserDefaults, but I'm not interested them to show up in the Settings.app. 在应用程序生存期内,我还有另外两个值存储在NSUserDefaults中,但我不希望它们显示在Settings.app中。 Is it possible at all that the number of values in settings.bundle will be different from actual number of key/value pairs, stored in the NSUserDefaults? settings.bundle中的值数量是否可能与存储在NSUserDefaults中的键/值对的实际数量完全不同? What has to be done in order to manage it properly? 为了正确管理该怎么办?

Thanks, 谢谢,

Key/value pairs in your Settings bundle are managed by [NSUserDefaults standardUserDefaults] , but there's nothing to stop you from adding your own keys and values to manage. 您的“设置”捆绑包中的键/值对由[NSUserDefaults standardUserDefaults]管理,但没有什么可以阻止您添加自己的键和值进行管理。 They won't show up in the Settings screen for your app unless you add them to the bundle's property list. 除非您将它们添加到捆绑软件的属性列表中,否则它们不会显示在您的应用程序的“设置”屏幕中。

Just register, store and retrieve user defaults the same way whether from your Settings bundle or not; 无论是否从“设置”捆绑包中进行注册,存储和检索用户默认值,都可以使用相同的方法; there's nothing additional that needs to be done. 无需执行其他任何操作。

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

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