Reputation: 9157
How can I extract a CLRegion
or CLLocationCoordinate2D
or latitude/longitude points based on a correctly written country name? Would CLGeocoder
work like this:
CLGeocoder *geoCode = [[CLGeocoder alloc] init];
[geoCode geocodeAddressString:@"Singapore" completionHandler:^(NSArray *placemarks, NSError *error) {
if (!error) {
CLPlacemark *place = [placemarks objectAtIndex:0];
NSLog(@"%i,%i", place.//what would i put here);
}
}];
What variable does a CLPlacemark
hold that tells the address?
Upvotes: 3
Views: 1371
Reputation: 9157
Never mind figured it out:
CLGeocoder *geoCode = [[CLGeocoder alloc] init];
[geoCode geocodeAddressString:@"Singapore" completionHandler:^(NSArray *placemarks, NSError *error) {
if (!error) {
CLPlacemark *place = [placemarks objectAtIndex:0];
CLLocation *location = place.location;
CLLocationCoordinate2D coord = location.coordinate;
NSLog(@"%g is latitude and %g is longtitude", coord.latitude, coord.longitude);
}
}];
Upvotes: 5