12

What's the difference between NSLocale currentLocale vs autoupdatingCurrentLocale? It's not obvious from reading the documentation.

Boon
  • 40,656
  • 60
  • 209
  • 315

2 Answers2

5

When the user changes their system locale settings, the autoupdating one automatically updates to the new locale.

Catfish_Man
  • 41,261
  • 11
  • 67
  • 84
2

The currentLocale only retrieve an locale object one time from the current user's settings. autoupdatingCurrentLocale updates the locale object on the fly so you don't need to validate. You might think autoupdateingCurrentLocale is the prefer way, it is per Apple documentation; however, since the returned object may be cached, you don't really need to hold on to it indefinitely when using currentLocale, verse autoupdateingCurrentLocale. If you are using autoupdatingCurrentLocale, note that this API do not cache the locale object, so you will need a way to compute cache upon receipt. One way is to use notification such as NSCurrentLocaleDidChangeNotification method call.

James L
  • 31
  • 1