Last active
August 29, 2015 14:18
-
-
Save felix-schwarz/b58aa4d37eb3cee5de87 to your computer and use it in GitHub Desktop.
NSTimeZone+ISCLLocation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSTimeZone+ISCLLocation.h" | |
… | |
NSTimeZone *timeZone = [NSTimeZone localTimeZone]; | |
CLLocation *location = nil; | |
NSString *countryCode = nil; | |
// Getting an approximate location | |
location = [timeZone approximateLocation]; | |
// Getting an ISO3166 country code | |
countryCode = [timeZone ISO3166CountryCode]; | |
if (location != nil) | |
{ | |
// Location found in database | |
NSLog(@"Location of this timezone: %@", location); | |
} | |
else | |
{ | |
// No location found in database. | |
NSLog(@"No location found for timezone %@", timeZone.name); | |
} | |
// Getting an ISO 3166 country code | |
if (countryCode != nil) | |
{ | |
// Location found in database | |
NSLog(@"Country of this timezone: %@", countryCode); | |
} | |
else | |
{ | |
// No location found in database. | |
NSLog(@"No country found for timezone %@", timeZone.name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment