Skip to content

Instantly share code, notes, and snippets.

@felix-schwarz
Last active August 29, 2015 14:18
Show Gist options
  • Save felix-schwarz/b58aa4d37eb3cee5de87 to your computer and use it in GitHub Desktop.
Save felix-schwarz/b58aa4d37eb3cee5de87 to your computer and use it in GitHub Desktop.
NSTimeZone+ISCLLocation example
#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