I am parsing an NSString from JSON and then the value is displayed in a UILable, the value contains numbers like @"12" , @"13"
Now when I do this:
self.lable.text = @"12";
the label display the value in arabic numbers ( ١٢ )
I have tried to parse the JSON response as NSNumber then use NSNumberFormatter to force the "en_US" locale in the below code segment but it didn't work.
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US"]];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
[numberFormatter setMaximumFractionDigits:0];
[numberFormatter setMinimumFractionDigits:0];
NSString *formattedNumberString = [numberFormatter stringFromNumber:number];
self.lable.text = formattedNumberString;
My app language is "English - development language" which is listed under the info tab in the project section.
The region of the device I am running the app on is set to "United States" and the language is set to "English"
I have tried to run [NSLocale currentLocale] to double check but I got "en_US"
I am stuck with this issue, any pointers and help is appreciated.
"12"is not the NSString value for 12.@"12"is the NSString value for 12."12"is achar*string value for 12, which would usually cause a crash when assigned to atextproperty, but which might occasionally result in apparently "normal" but bogus operation. - Hot Licks