objective c – How do I get an IOS time zone?


When I go to the iPhone settings when my app is running, change the time zone and come back to the app, I want to reset the time to the changed time zone. But I always get the same time zone value back. (Maybe the default time zone?)

    NSCalendar *calendar = [NSCalendar currentCalendar];
    
    [NSTimeZone resetSystemTimeZone];
    //NSTimeZone *deviceTimeZone = [NSTimeZone localTimeZone];
    NSTimeZone *deviceTimeZone = [NSTimeZone systemTimeZone];
    [calendar setTimeZone:deviceTimeZone];

However, when I obtained the time zone with the code above, the return values for localTimeZone and systemTimeZone were the same, and when I tried it on my iPhone, it always returned a certain time zone regardless of the time zone changed in the settings. The strange thing is that the Mac Xcode simulator reflects the time zone changed in the settings. How can I get the same results as Mac on my iPhone? If anyone knows, please help..

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img