You can do the same job by calling Google API or Yahoo API but APTimeZones works locally, offline and with no limits inherented to hosted solutions.
Usage:
//Ukraine location
CLLocation *location = [[CLLocation alloc] initWithLatitude:50.449846
                                                  longitude:30.523629];
NSTimeZone *timeZone = [[APTimeZones sharedInstance] timeZoneWithLocation:location];
NSLog(@"%@", timeZone);
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:@"New York" completionHandler:^(NSArray *placemarks, NSError *error) {
    if (placemarks.count) {
        CLPlacemark *placemark = placemarks[0];
        CLLocation *location = placemark.location;
        NSString *countryCode = placemark.addressDictionary[@"CountryCode"];
        NSTimeZone *timeZone = [[APTimeZones sharedInstance] timeZoneWithLocation:location
                                                                      countryCode:countryCode];
        NSLog(@"%@", timeZone);
    } 
}];
Version 1.1:
We've added some handy categories with version 1.1 to make timezones magic even more easy.CLLocation+APTimeZones
CLPlacemark+APTimeZones
Usage:
CLLocation *location = ...
NSLog(@"%@", location.timeZone);
CLPlacemark *placemark = ...;
NSLog(@"%@", placemark.timeZone);
|  |  | 
Download: https://github.com/Alterplay/APTimeZones/archive/master.zip
No comments:
Post a Comment