title: localizing currencies in iphone app
body: <p>I am testing my app. All is working fine except when I change locales to Germany.</p>
  
  <p>Basically you input 2 values in your local currency, a calculation happens and the user gets info back. </p>
  
  <p>Users numeric inputs are handled well. That is, on "Editing Did End" a method executes that converts the number to its local currency equivalent. So if US users enters 10000 they will be returned $10,000.00. Here's the code:</p>
  
  <pre><code>- (NSMutableString *) formatTextValueToCurrency: (NSMutableString *) numberString {
  
  
  NSNumber *aDouble = [NSNumber numberWithFloat: [numberString floatValue]];
  NSMutableString *aString = [NSMutableString stringWithCapacity: 20];
  NSLocale *theLocale;
  
  
  NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init];
  
  [currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4];
  [currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle];
  theLocale = [NSLocale currentLocale];
  [currencyStyle setLocale: theLocale];
  
  [aString appendString: [currencyStyle stringFromNumber:aDouble]];   
  
  [currencyStyle release];
  
  return aString;
  
  }
  </code></pre>
  
  <p>However a problem occurs when I want to process the above currency values to get the user his/her info. That is, the app will now needs to get 10000 from $10,000.00 (or whatever currency) to send into the calculation method. Here's the code:</p>
  
  <pre><code>- (float) getValueFromCurrency: (id) sender {
  
  NSNumber *aDouble = [NSNumber numberWithFloat: 0.0];
  UITextField *textField = (UITextField *) sender;
  NSMutableString *aString= [NSMutableString stringWithCapacity: 20]; 
  NSLocale *theLocale;
  
  float result;
  
  NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init];    
  
  [currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4];
  [currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle];
  
  theLocale = [NSLocale currentLocale];
  
  [currencyStyle setLocale: theLocale];
  NSLog(@"The locale is %@", currencyStyle.locale.localeIdentifier); 
  //Above NSLog looks good because it returns de_DE 
  
  [aString appendString: textField.text];
  //The append from text field to string is good also
  
  aDouble = [currencyStyle numberFromString: aString];
  //For some reason, nil is returned
  
  result = [aDouble floatValue];
  
  [currencyStyle release];
  
  return result;
  }
  </code></pre>
  
  <p>For some reason the US, UK, Japanese and Irish locales are fine. </p>
  
  <p>Continental European countries are not working.</p>
  
  <p>Any advice on how to fix this would be great.</p>