Skip to content

Instantly share code, notes, and snippets.

@chancyWu
Last active August 29, 2015 14:02
Show Gist options
  • Save chancyWu/46c0c8fd19550a1e7343 to your computer and use it in GitHub Desktop.
Save chancyWu/46c0c8fd19550a1e7343 to your computer and use it in GitHub Desktop.
NSLocale usage
NSLocale *lcl = [[NSLocale alloc] initWithLocaleIdentifier:@"en_SG"];
NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init];
[fmtr setNumberStyle:NSNumberFormatterCurrencyStyle];
[fmtr setLocale:lcl];
NSLog(@"Current Locale: %@", [NSLocale currentLocale]);
NSLog(@"Available Locales: %@",[NSLocale availableLocaleIdentifiers]);
NSLog( @"%@", [lcl displayNameForKey:NSLocaleCurrencySymbol value:@"en_SG"] );
NSLog( @"%@", [fmtr currencySymbol] );
NSLog(@"CurrencyCode: %@", [lcl objectForKey:NSLocaleCurrencyCode]);
NSLog(@"CurrencySymbol: %@", [lcl objectForKey:NSLocaleCurrencySymbol]);
NSLog(@"CountryCode: %@",[lcl objectForKey:NSLocaleCountryCode]);
NSLog(@"CountryName: %@", [lcl displayNameForKey:NSLocaleCountryCode value:[lcl objectForKey:NSLocaleCountryCode]]);
NSLocale *phLcl = [[NSLocale alloc] initWithLocaleIdentifier:@"en_PH"];
NSLog(@"en_PH CurrencyCode: %@",[phLcl objectForKey:NSLocaleCurrencyCode]);
NSLog(@"en_PH CurrencySymbol: %@", [phLcl objectForKey:NSLocaleCurrencySymbol]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment