MCKapur
MCKapur

Reputation: 9157

Coordinates/Region from Country Name

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

Answers (1)

MCKapur
MCKapur

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

Related Questions