LTZTimeZones is a drop-in time zone selection manager that works completely offline. LTZTimeZones uses location and time zone data gathered from GeoNames, along with some modifications.
-
Drag-and-drop the
LTZTimeZones
folder into your Xcode project. -
Initialize a shared instance of
LTZTimeZones
:
#import "LTZTimeZones.h"
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul), ^{
[LTZTimeZones sharedManager];
});
- Display the
LTZSearchController
:
#import "LTZSearchController.h"
LTZSearchController *searchController = [[LTZSearchController alloc] init];
// Don't forget to set the delegate!
searchController.delegate = self;
[self.navigationController pushViewController:searchController animated:YES];
- Implement
LTZSearchDelegate
:
- (void)searchDidSelectLocation:(LTZLocation *)location {
// Pop the search controller.
[self.navigationController popViewControllerAnimated:YES];
// Do something useful with `location`!
selectionLabel.text = [NSString stringWithFormat:@"%@\n%@ (%@)", location.name, location.timeZone.name, location.timeZone.abbreviation];
}
See the TimeZonesSample demo project included in this repository for a working example of the project.
LTZTimeZones works on iOS 7 and above.
LTZTimeZones is released under the MIT License.