views:

70

answers:

1

Hi,

i get a nsstring from a nsdictionary via:

inputString = [dataUsage valueForKey:@"amount"];

after that the string looks like: 23,56

how can i convert this string into a nsnumber?

i have tried the following:

NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *number = [formatter numberFromString:inputString];
[formatter release];

but this does not work. I think the problem is, that the "delimiter" is a comma. How can i fix this?

regards, patrick

+2  A: 

-[NSNumberFormatter setLocale:]

You could also use setDecimalSeparator:, but setLocale: will take care of that as well.

Dave DeLong
thanks! setLocale helps
patrickS