How to get NSNumberFormatter currency style from ISOCurrencyCodes?
Use the setCurrencyCode:
method of NSNumberFormatter
.
[numberFormatter setCurrencyCode:@"EUR"];
or
[numberFormatter setCurrencyCode:@"USD"];
Keep in mind that even though the desired currency symbol will be used, the resulting currency value string is still going to be formatted based on the user's locale.
How to use NSNumberFormatter to display currency?
You can configure NSNumberFormatter like that :
NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init];
[numFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numFormatter setCurrencySymbol:@"ct"];
[numFormatter setMultiplier:100];
NSNumber *myNumber = [NSNumber numberWithDouble:[@"0.058" doubleValue]];
How to get the Currency formatter with decimal and grouping separator in swift using ISOCode
The error comes from the way you cast your value to Int:
Int(1234567.89)
This rounds your floating-point value to 1234567
even before passing it to setAmountString
.
Try casting it to Float
instead, or not casting it at all. You also need to change your function signature from
func setAmountString (amountValue: Int, isoCodeStr: String)
to
func setAmountString (amountValue: Float, isoCodeStr: String)
NSNumberFormatter list of supported currencies
You can use the following to print the supported currencies.
NSLocale *locale = [NSLocale currentLocale];
for (NSString *code in [NSLocale ISOCurrencyCodes]) {
NSLog(@"%@ : %@", code, [locale displayNameForKey:NSLocaleCurrencyCode value:code]);
}
See if the out put is what you are looking for.
How to display correct Swedish currency on IOS?
I tried using
[currencyFormatter setCurrencyCode:@"SEK"];
but that did not give the correct output.
Then went through this link
A work around could be to append the string of the currency, though am not too sure whether that will fulfill your requirement.
Related Topics
Parse Cloud - Livequeries - iOS Client Doesn't Work
Can't Write Non Current User Objects by Pfuser Currentuser
Media_Err_Decode on HTML5 Video in iOS UIwebview After Many Plays
Objc Protocol Implementation in Swift
Can Push Notifications Be Used to Run Code Without Notifying User
How to Solve Mach-O-Linker Error in iOS7 & Xcode 5.0.1
Dateformatter Gives Wrong Time on Conversation
Does "Let _ = ..." (Let Underscore Equal) Have Any Use in Swift
iOS Wkwebview Swift JavaScript Enable
Shared Iad Banner Bannerviewdidloadad Not Being Called
Firebase Cloud Messaging Cannot Parse Topic Name
Fetch() Doing Get Instead of Post on React-Native (iOS)
App Crashes After Updating Coredata Model That Is Being Displayed in a UItableview
Selecting All The Items in UIcollectionview iOS, Even The Cells That Are Not Visible
Will Download Resume After Closing My App in Background Mode
iPhone - Memory Leak - Nsdata Datawithcontentsofurl & UIwebview