I'm struggling with getting a variable out of a block. Seems to be a pretty basic thing but I can't figure it out! How can I access it? e.g. usercity
out of the block? Usercity is declared as NSString in .h.
[ceo reverseGeocodeLocation: loc completionHandler:
^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
//NSLog(@"placemark %@",placemark);
//String to hold address
//NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
//NSLog(@"addressDictionary %@", placemark.addressDictionary);
//NSLog(@"placemark %@",placemark.region);
NSLog(@"Land %@",placemark.country); // Give Country Name
NSLog(@"City %@",placemark.locality); // Extract the city name
NSLog(@"Adresse %@",placemark.name);
//NSLog(@"location %@",placemark.ocean);
NSLog(@"Zip %@",placemark.postalCode); //ZipCode
NSLog(@"sonstiges %@",placemark.subLocality);
//Save values in variables
usercountry = placemark.country;
usercity = placemark.locality;
userzip = placemark.postalCode;
NSLog(@"usercity: %@",usercity);
//NSLog(@"location %@",placemark.location);
}
];