Take the 2-minute tour ×

I am using the following code to receive placemarks from CLGeocoder, and I want to display only the city in another textview on the same viewcontroller. How would I parse out the city from this array? It isn't an NSDictionary or anything, so I am stuck as to what to do.

CLGeocoder *geocoder = [[CLGeocoder alloc] init];

[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
    NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
    if (error){
    NSLog(@"Received placemarks: %@", placemarks);

My log for a given placemark is as follows:

<__NSArrayM 0x1a0b3810>( 937–961 Sunnyvale Saratoga Rd, 937–961 Sunnyvale Saratoga Rd, Sunnyvale, CA 94087, United States @ <+37.35984860,-122.03235910> +/- 100.00m )


<__NSArrayM 0x19576ac0>( 5600 Van Nuys Blvd, 5600 Van Nuys Blvd, Van Nuys, CA 91401-4602, United States @ <+34.17257000,-118.44794450> +/- 100.00m, region (identifier <+34.17257001,-118.44794464> radius 57.64) <+34.17257001,-118.44794464> radius 57.64m )

How could I get the Sunnyvale or Van Nuys part out to display as a string?

share|improve this question
Ah, ok so it returns CLPlacemark objects that have properties associated with it. Completely misread the documentation, I thought it returned a mess of a string. –  Hudson Buddy Nov 27 '12 at 7:15
add comment

1 Answer

up vote 1 down vote accepted

Use CLPlacemark's properties

CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:yourLocation completionHandler:^(NSArray *placemarks, NSError *error) {
  CLPlacemark *placemark = [placemarks objectAtIndex:0];
  NSString *strCity = [placemark locality];
share|improve this answer
I answered my own question but thanks anyway! –  Hudson Buddy Nov 30 '12 at 2:25
add comment

Your Answer


