سؤال

i have looked every where and didn't found an answer for this one.

i'm building an iOS app that uses the location (lat + long) of the user creating a CLPlacemark, and sends the street + country to the server and get back a respond according to this location.

now the server can get only hebrew values, and the CLPlacemark values are changes according to the operation system of the user.

can i set a const language to the CLPlacemark class instance? i want that the CLPlacemark will return hebrew regardless from the operation system of the user

here is my code:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    geoCoder = [[CLGeocoder alloc]init];
    [self.geoCoder reverseGeocodeLocation:locationManager.location completionHandler:
     ^(NSArray *placemarks, NSError *error) {

         CLPlacemark *placemark = [placemarks objectAtIndex:0];
         placemark.

         self.countryTextBox.text =[placemark.addressDictionary valueForKey:@"Country"];
         self.citiTextBox.text =[placemark.addressDictionary valueForKey:@"City"];
         self.streetTextBox.text =[placemark.addressDictionary valueForKey:@"Street"];
         self.zipCodLbl.text =[placemark.addressDictionary valueForKey:@"ZIP"];


         //NSLog(@"%@",placemark.addressDictionary);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"Country"]);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"City"]);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"Street"]);
         NSLog(@"%@",[placemark.addressDictionary valueForKey:@"ZIP"]);

         [locationManager stopUpdatingLocation];
         [self.animationBar stopAnimating];



             }];

}

thanks a lot.

idan.

هل كانت مفيدة؟

المحلول

after a hard days of searching im finally solve it.

in the view did load just add this line of code:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"he"] forKey:@"AppleLanguages"];

if this will help somebody - great!

نصائح أخرى

Messing with user's system preference is BAD PRACTICE!! You should use instead:

NSLocale *yourLocal = [[NSLocale alloc] initWithLocaleIdentifier:@"de"];
[geoCoder reverseGeocodeLocation: preferredLocale:yourLocal completionHandler:
     ^(NSArray *placemarks, NSError *error) {

}];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top