what is the difference between [NSLocale preferredLanguages] and [[NSUserDefaults standardUserDefaults] objectForKey:@“AppleLanguages”]?

后端 未结 2 1225
生来不讨喜
生来不讨喜 2021-01-25 10:30

What is the difference between [NSLocale preferredLanguages] and [[NSUserDefaults standardUserDefaults] objectForKey:@\"AppleLanguages\"]?

相关标签:
2条回答
  • 2021-01-25 11:20

    Both are meant to return the same thing, the first one is just more convenient.

    The Apple Documentation says: for [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]

    The returned array contains the languages associated with the AppleLanguages key in the user's preferred order.

    The Apple Documentation says: for [NSLocale preferredLanguages]

    The user's language preference order as an array of NSString objects,

    0 讨论(0)
  • 2021-01-25 11:30

    You should use [NSLocale preferredLanguages], use [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] if you are supporting Mac OS X 10.4 or earlier.

    0 讨论(0)
提交回复
热议问题