NSUserDefaults已经拥有密钥和价值对? -迅速

时间:2015-02-19 01:32:55

标签: swift nsuserdefaults

我在我的应用程序中使用NSUserDefaults,当我启动应用程序时,NSUserDefaults似乎已经有了默认值。当我在应用程序的开头打印NSUserDefaults作为字典时,它具有默认值。这就是将它打印成字典的样子:

[MSVLoggingMasterSwitchEnabledKey: 0, NSLanguages: (
en,
fr,
de,
"zh-Hans",
"zh-Hant",
ja,
nl,
it,
es,
"es-MX",
ko,
pt,
"pt-PT",
da,
fi,
nb,
sv,
ru,
pl,
tr,
uk,
ar,
hr,
cs,
el,
he,
ro,
sk,
th,
id,
ms,
"en-GB",
"en-AU",
ca,
hu,
vi,
hi
), AppleITunesStoreItemKinds: (
audiobook,
"tv-episode",
booklet,
software,
"software-update",
"itunes-u",
ringtone,
"tv-season",
movie,
mix,
newsstand,
song,
wemix,
tone,
artist,
"podcast-episode",
podcast,
document,
eBook,
album,
"music-video"
), AppleKeyboardsExpanded: 1, NSInterfaceStyle: macintosh, AppleKeyboards: (
"en_US@hw=US;sw=QWERTY",
"emoji@sw=Emoji",
"en_US@hw=US;sw=QWERTY"
), AppleLocale: en_US, AppleLanguages: (
en,
fr,
de,
"zh-Hans",
"zh-Hant",
ja,
nl,
it,
es,
"es-MX",
ko,
pt,
"pt-PT",
da,
fi,
nb,
sv,
ru,
pl,
tr,
uk,
ar,
hr,
cs,
el,
he,
ro,
sk,
th,
id,
ms,
"en-GB",
"en-AU",
ca,
hu,
vi,
hi
)]
[MSVLoggingMasterSwitchEnabledKey: 0, NSLanguages: (
en,
fr,
de,
"zh-Hans",
"zh-Hant",
ja,
nl,
it,
es,
"es-MX",
ko,
pt,
"pt-PT",
da,
fi,
nb,
sv,
ru,
pl,
tr,
uk,
ar,
hr,
cs,
el,
he,
ro,
sk,
th,
id,
ms,
"en-GB",
"en-AU",
ca,
hu,
vi,
hi
), AppleITunesStoreItemKinds: (
audiobook,
"tv-episode",
booklet,
software,
"software-update",
"itunes-u",
ringtone,
"tv-season",
movie,
mix,
newsstand,
song,
wemix,
tone,
artist,
"podcast-episode",
podcast,
document,
eBook,
album,
"music-video"
), AppleKeyboardsExpanded: 1, NSInterfaceStyle: macintosh,        
AppleKeyboards: (
"en_US@hw=US;sw=QWERTY",
"emoji@sw=Emoji",
"en_US@hw=US;sw=QWERTY"
), AppleLocale: en_US, AppleLanguages: (
en,
fr,
de,
"zh-Hans",
"zh-Hant",
ja,
nl,
it,
es,
"es-MX",
ko,
pt,
"pt-PT",
da,
fi,
nb,
sv,
ru,
pl,
tr,
uk,
ar,
hr,
cs,
el,
he,
ro,
sk,
th,
id,
ms,
"en-GB",
"en-AU",
ca,
hu,
vi,
hi
)]
[MSVLoggingMasterSwitchEnabledKey: 0, NSLanguages: (
en,
fr,
de,
"zh-Hans",
"zh-Hant",
ja,
nl,
it,
es,
"es-MX",
ko,
pt,
"pt-PT",
da,
fi,
nb,
sv,
ru,
pl,
tr,
uk,
ar,
hr,
cs,
el,
he,
ro,
sk,
th,
id,
ms,
"en-GB",
"en-AU",
ca,
hu,
vi,
hi
), AppleITunesStoreItemKinds: (
audiobook,
"tv-episode",
booklet,
software,
"software-update",
"itunes-u",
ringtone,
"tv-season",
movie,
mix,
newsstand,
song,
wemix,
tone,
artist,
"podcast-episode",
podcast,
document,
eBook,
album,
"music-video"
), AppleKeyboardsExpanded: 1, NSInterfaceStyle: macintosh,    
AppleKeyboards: (
"en_US@hw=US;sw=QWERTY",
"emoji@sw=Emoji",
"en_US@hw=US;sw=QWERTY"
), AppleLocale: en_US, AppleLanguages: (
en,
fr,
de,
"zh-Hans",
"zh-Hant",
ja,
nl,
it,
es,
"es-MX",
ko,
pt,
"pt-PT",
da,
fi,
nb,
sv,
ru,
pl,
tr,
uk,
ar,
hr,
cs,
el,
he,
ro,
sk,
th,
id,
ms,
"en-GB",
"en-AU",
ca,
hu,
vi,
hi
)]

1 个答案:

答案 0 :(得分:0)

是的,对于语言,有一些预设值。如您所示,您粘贴的项目是语言。甚至引号中的项目如“zh-Hans”也指的是语言,在这种情况下是不同的中文方言。

gnustep.org上注意到“NSLanguages默认值用于设置本地化的常量。”