我正在使用设置包来存储我的应用的基本用户首选项。启动后,我将设置首选项的默认值(如另一篇文章中所述)。但是,如果我启动settings.app并进行更改,则会丢失一些首选项。
这是我的捆绑文件中的组:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Title</key>
<string>Word Bucket</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Auto-create bucket</string>
<key>Key</key>
<string>bucket</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Words</string>
<key>Key</key>
<string>bucket_size</string>
<key>KeyboardType</key>
<string>NumberPad</string>
<key>DefaultValue</key>
<string>10000</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>Words</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string>Bucket</string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>bucket_name</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>Name</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>Title</key>
<string>Interface</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Key</key>
<string>colour_scheme</string>
<key>DefaultValue</key>
<string>Black</string>
<key>Title</key>
<string>Colour Scheme</string>
<key>Titles</key>
<array>
<string>Black</string>
<string>Blue</string>
<string>Green</string>
</array>
<key>Values</key>
<array>
<string>Black</string>
<string>Blue</string>
<string>Green</string>
</array>
</dict>
<dict>
<key>Title</key>
<string>About</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>Title</key>
<string>Version</string>
<key>Key</key>
<string>version_preference</string>
<key>DefaultValue</key>
<string>0.4</string>
</dict>
</array>
<key>StringsTable</key>
<string>Root</string>
<key>Title</key>
<string></string>
</dict>
</plist>
在进行编辑之前(首次设置默认值之后),以下内容存储在设置中;
bucket = 1;
"bucket_name" = Bucket;
"bucket_size" = 10000;
"colour_scheme" = Black;
"version_preference" = "0.5";
在更改首选项后,他们会报告以下内容;
bucket = 1;
"last_bucket" = 201203;
除了委托中的initialize方法中的初始设置之外,我没有进一步更改首选项。
任何建议表示赞赏。