NSLocale currentLocale与autoupdatingCurrentLocale之间的区别是什么?

时间:2014-04-02 21:04:32

标签: foundation nslocale

NSLocale currentLocale与autoupdatingCurrentLocale之间的区别是什么?通过阅读文档并不明显。

2 个答案:

答案 0 :(得分:3)

当用户更改其系统区域设置时,自动更新会自动更新为新区域设置。

答案 1 :(得分:0)

currentLocale仅从当前用户的设置中检索一次语言环境对象。 autoupdatingCurrentLocale动态更新语言环境对象,因此您无需验证。您可能认为autoupdateingCurrentLocale是首选方式,它是根据Apple文档;但是,由于返回的对象可能被缓存,因此在使用currentLocale,autoupdateingCurrentLocale时,您并不需要无限期地保留它。 如果您使用的是autoupdatingCurrentLocale,请注意此API不会缓存区域设置对象,因此您需要一种在收到时计算缓存的方法。一种方法是使用通知,例如NSCurrentLocaleDidChangeNotification方法调用。