Reputation: 1310
I want to know the continent name in which the user is located. Can i get it from regional setting or have to use some service to fetch continent from current lat/lng? If service, which one will be appropriate to fetch continent details?
Thanks
Upvotes: 2
Views: 729
Reputation: 1207
Check out this utility: https://github.com/Alterplay/APTimeZones.
It gets NSTimeZone from CLLocation.
Upvotes: 0
Reputation: 7226
Well this can be done like this
For Example I have made a code to get the timezone.
NSTimeZone *localTime = [NSTimeZone systemTimeZone];
NSLog(@" - current local timezone is %@",localTime);
I am getting an output as follows - current local timezone is Asia/Kolkata (GMT+05:30) offset 19800
So I got the whole timezone. What I do now in this is add this in an NSString
. Then use the property of the NSString
class componentsSeparatedByString
to get the "/" operator.
The full code is as follows :-
NSTimeZone *localTime = [NSTimeZone systemTimeZone];
NSLog(@" - current local timezone is %@",localTime);
NSString *str = [NSString stringWithFormat:@"%@",localTime];
NSArray *arr = [str componentsSeparatedByString:@"/"];
NSString *strHi = [arr objectAtIndex:0];
NSLog(@"%@",strHi);
According to this code you would get the value of strHi as Asia.
Hope this helps .
Upvotes: 3