objective c - localizing currencies in iphone app -


I'm testing my app when I change local people to Germany, even then all are working fine .

Basically you input 2 values ​​in your local currency, a calculation occurs and the user gets back information

User numeric input is well controlled. Is executing a method on "editing the end and end", which converts the number into its local currency counterpart. So if American users enter 10000, they will be returned $ 10,000.00. Here is the code:

  - (NSMutableString *) formatTextValueToCurrency: (NSMutableString *) number string {NSNumber * aouble = [NSNumber number with number: [number string flat value]]; NSMutableString * aString = [NSMutableString string withCapacity: 20]; NSLocale * theLocale; NSNumberFormatter * currencyStyle = [[NSNumberFormatter alloc] init]; [Currency Style Settlebervier: NSNumberFormatterBehavior10_4]; [Currency styling set number number: NSNumberFormatterCurrencyStyle]; TheLocale = [NSLock Challenge]; [Currency style sitelokel: theLocale]; [Astrangle Appendstring: [currency styling stringname: AWW]]; [Currency style release]; Astringe return; }  

However, a problem occurs when I want the user to process the above currency values ​​to get his information. That is, to send the app to the calculation method, 10,000 dollars (or whatever currency) will have to get 10000. Here's the code:

  - (float) getValueFromCurrency: (ID) sender {NSNumber * aouble = [NSF number with NSF number: 0.0]; UITextField * textField = (UITextField *) Sender; NSMutableString * aString = [NSMutableString string withCapacity: 20]; NSLocale * theLocale; Float result; NSNumberFormatter * currencyStyle = [[NSNumberFormatter alloc] init]; [Currency Style Settlebervier: NSNumberFormatterBehavior10_4]; [Currency styling set number number: NSNumberFormatterCurrencyStyle]; TheLocale = [NSLock Challenge]; [Currency style sitelokel: theLocale]; NSLog (@ "locale% @", currency style.locale.localeeidentifier); // looks good over NSLog because it gives de_DE [aString appendString: textField.text]; // It is also good to add text from the string to the string a double = [currency styling numberframestrings: aString]; // For any reason zero zero result = [a double float value] is returned; [Currency style release]; Return result; }  

The US, the UK, the Japanese and Irish Locals are OK for any reason.

Continental European countries are not working.

Any advice about how to fix this will be great.

That is, those who work for your code, there are thousands of commuter commas, and there is a decimal point point (full stop), then 10000 dollars and 50 cents will be 10,000.50.

Thousands separator points (full stop) in mainland Europe (Germany etc) And the decimal separator is a comma, so the above mentioned value in Germany will be 10.000,50

NSNumberFormatter has two modes that you want to see: -

  • (NSString *) currencyDecimalSeparator <
  • (NSString *) Mingling separator

You can find a list in WIKI () countries for each format, and to see that your problem is only for a group / P>

I hope that helps.

Cheers,

Kevin


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -