3

I use this code to set a label with a location string

locationString = [[NSString alloc] initWithFormat:@"%@%@ - %@ %@%@", thoroughfare,subThoroughfare,postalCode, locality,countryCode]; locationLabel.text = locationString; 

where thoroughfare, subThoroughfare, postalCode, locality,countryCode are obtained from a placemark.

Now, I'd like to visualize this string according the current locale. Have I specify a string format for each locale in which I'm interested or there is a simpler way to obtain this?

Thanks, Fran

0

2 Answers 2

1

you can use following function

-(void) setLocation:(NSString *)latitude withLongitude:(NSString *)longitude { CLGeocoder *geocoder = [[CLGeocoder alloc] init]; CLLocation *location = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] longitude: longitude doubleValue]]; CLGeocodeCompletionHandler completionHandler = ^ (NSArray *placemarks, NSError *error){ if (error){ NSLog(@"error in fetching location <%@>",error); return ; } if ( placemarks && placemarks.count >0){ CLPlacemark *mark = [placemarks objectAtIndex:0]; NSString *addresstring = [[mark addressDictionary] objectForKey:@"FormattedAddressLines"] componentsJoinedByString:@","]; *//fetched addressDictionary for key FormattedAddressLines* } 
Sign up to request clarification or add additional context in comments.

Comments

0

The addressDictionary property of the placemark object should resolve in part the problem with its FormattedAddressLines array.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.