Question

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

Was it helpful?

Solution 2

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

OTHER TIPS

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*

            }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top