NSTimeZone: what is the difference between localTimeZone and systemTimeZone?

前端 未结 2 972
长情又很酷
长情又很酷 2020-12-01 07:50

Under NSTimeZone class, there is both +localTimeZone and +systemTimeZone. I did a test on iphone simulator, both return NSTimeZone object indicating the same timezone. What

2条回答
  •  佛祖请我去吃肉
    2020-12-01 07:57

    The docs are a wealth of useful information for this kind of thing. In this case, they say:

    • localTimeZone is the default time zone for the current application. This can be set by the user or programmatically in the app (or possibly in other ways). It's basically a pointer to defaultTimeZone with a level of indirection; if the default time zone changes, localTimeZone will change as well.
    • systemTimeZone, on the other hand, is the time zone used by the core system. A cached value for this will not change if the system time zone changes during the application's execution, unlike localTimeZone.

提交回复
热议问题