Reputation: 446
I've been looking for a while now and have done a good amount of research as well as experimenting, but I cannot find a way to retrieve the value stored in a users settings for Time Zone Support on iOS devices.
I have looked into NSTimeZone convenience methods +systemTimeZone, +resetSystemTimeZone, +defaultTimeZone, +localTimeZone. I even fully understand the differences between them and how we can set our own default time zone per application, and how first call to default returns value for system. System then gets cached and needs to be reset if the device changes time zones.
Problem is, systemTimeZone is always where the device is actually located, not the value set in the device's settings under Time Zone Support.
I have even looking into [[NSCalendar currentCalendar] timeZone] as well as [[NSCalendar autoupdatingCurrentCalendar] timeZone]].
I even tried [[[NSLocale currentLocale] objectForKey:NSCurrentCalendar] timeZone] and [[[NSLocale autoupdatingCurrentLocale] objectForKey:NSCurrentCalendar] timeZone]
Nothing returns the value of the device's Settings.app -> Mail, Contacts, Calendars -> Time Zone Support -> Time Zone.
Does anyone know how to retrieve the value of the Settings.app -> Mail, Contacts, Calendars -> Time Zone Support -> Time Zone setting?
Thanks and Cheers!
Upvotes: 4
Views: 406
Reputation: 308
Forgive me if this is way off the mark, but are you sure that you actually want to access the Time Zone Support setting from the following location?
I would not have made this post otherwise, but you got me thinking when you stated the following:
Problem is, systemTimeZone is always where the device is actually located, not the value set in the device's settings under Time Zone Support.
Unfortunately, your statement here is not quite correct. +systemTimeZone
will return the time zone for where the device is actually located unless the user has turned off Set Automatically and chosen a particular time zone at the following location:
This will change the time zone to be used system-wide, which is immediately reflected by the time in the status bar adjusting for the new setting.
What you have been trying access previously seems focused on how calendar appointments are represented in the native Calendar.app, and would appear to be private to that application (along with the rest of the settings in that area).
If you are looking for access to the effective system-wide time zone setting that can be modified by the user then Time Zone under Date & Time is the way to go. This will be the value returned by +systemTimeZone
.
On the other hand if you really must access the Time Zone Support setting under Mail, Contacts, Calendars I'm afraid I cannot help you and I apologise for the distraction.
Upvotes: 2