【问题标题】:Bind user defaults to different identifier将用户默认值绑定到不同的标识符
【发布时间】:2010-10-04 03:24:33
【问题描述】:

我有一个首选项窗格包(它在系统首选项中运行)。我使用 Interface Builder 设计了界面,其中我将“自动启动”复选框绑定到 Shared User Defaults。这很好用,但它会将偏好写入 com.apple.systempreferences。我想将我的偏好保留在 com.example.mybundle 默认值中。我该怎么做?

我想我需要在 Interface Builder 中添加一个 User Defaults 控制器,但是如何告诉它与 com.example.mybundle 进行映射?

谢谢大家!

【问题讨论】:

    标签: objective-c cocoa binding bundle nsuserdefaults


    【解决方案1】:

    您需要绑定到一个 NSDictionaryController,它的持久性是通过 -[NSUserDefaults persistentDomainForName:]-[NSUserDefaults setPersistentDomain:forName:] 管理的,尽管坦率地说,使用 +[NSDictionary dictionaryWithContentsOfFile:]-[NSDictionary writeToFile:atomically:] 一样容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-12
      相关资源
      最近更新 更多