NSNumberFormatter for Currency

I'm using NSNumberFormatter for currency formatting. I have explicitly mentioned the currency symbol, currency group separator, currency decimal separator. It is working as expected. But, when i change the region format to some specific region in device settings, It is not working and the formatting of the text is also getting affected. How to overcome with this ? I want the formatter to format based on the properties that i have set to it and not based on device level region settings....Read more

regional settings - Can NSNumberformatter convert number to string replacing period with comma if appropriate for region

I need to change a textfield.text from one number to another but retain the regional use of comma or period for decimal eliminator.ANSNumberFormatter* nf = [[NSNumberFormatter alloc] init]; nf.locale = [NSLocale currentLocale]; NSNumber *n = [nf numberFromString:textfield.text]; //converts comma to period if neededfloat number = [n floatValue];float newnumber= number * factor;BNow I need to reload into the textfield.text the new number as string and convert period to comma if called for by the region. In other words reverse engineer the ...Read more

What is NSNumberFormatter adding elipsis?

I recently added a method to the object that takes care of scoring to a game I'm working on to return a string using NSNumberFormatter. I've just received a score of 163,930,640, and it is displayed this way in one place. But in another place, on a text label, it is displayed as 163,930,6.... I'm pretty sure all digits were displayed during active game play, but it switched to having an elipsis when it stopped being updated. Here is how I create the label:self.scoreLabel = [[UILabel alloc] init];self.scoreLabel.hidden = YES;self.scoreLabel.text...Read more

NSNumberFormatter confused about minus?

Check this out:(lldb) po NSNumberFormatter().numberFromString("+10.6")nil(lldb) po NSNumberFormatter().numberFromString("10.6")▿ Optional(10.6)(lldb) po NSNumberFormatter().numberFromString("-10.6")▿ Optional(-10.6)So apparently, adding a minus sign to a number is perfectly valid, but a plus sign is not. Is this expected behaviour, and it so, anyone know why?...Read more