Last active
August 29, 2015 14:16
-
-
Save adriantofan/6f91841d8f6594f2f364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSLocale *locale = [NSLocale currentLocale]; | |
// [locale localeIdentifier] fr_FR (i'm in france) | |
NSLog(@"current locale: %@", locale.localeIdentifier); | |
NSArray* preferredLanguages = [NSLocale preferredLanguages]; | |
NSLog(@"preferredLanguages: %@", preferredLanguages); | |
// en,fr ( the interface is in english ) | |
NSString* code = [locale objectForKey:NSLocaleCurrencyCode]; | |
NSLog(@"NSLocaleCurrencyCode: %@", code); | |
// EUR (based onlocaleIdentifier) | |
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]; | |
[currencyFormatter setLocale:[NSLocale currentLocale]]; | |
[currencyFormatter setMaximumFractionDigits:2]; | |
[currencyFormatter setMinimumFractionDigits:2]; | |
[currencyFormatter setAlwaysShowsDecimalSeparator:YES]; | |
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; | |
NSNumber *someAmount = [NSNumber numberWithFloat:5.00]; | |
NSString *stringAmount = [currencyFormatter stringFromNumber:someAmount]; | |
NSLog(@"%@",stringAmount); | |
// 5,00 € |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment