nslocale

Check language in iOS app

橙三吉。 提交于 2019-11-29 12:24:34
问题 Task is : I have got two UIImageViews, and I want present ImageView1 if system language is Ukrainian, and if it is not Ukrainian(English/Polish etc) I want present ImageView2. I tried : println(NSUserDefaults.standardUserDefaults().objectForKey("AppleLanguages")) but this code gives only list of available languages. I also tried var language: AnyObject? = NSLocale.preferredLanguages().first but how can I compare this variable with English or Ukrainian language? 回答1: Swift 3 You can take the

NSLocale Swift 3

给你一囗甜甜゛ 提交于 2019-11-29 09:22:46
How do I get the currency symbol in Swift 3? public class Currency: NSObject { public let name: String public let code: String public var symbol: String { return NSLocale.currentLocale().displayNameForKey(NSLocaleCurrencySymbol, value: code) ?? "" } // MARK: NSObject public init(name: String, code: String) { self.name = name self.code = code super.init() } } I know NSLocale got renamed to Locale, but displayNameForKey got removed and I only seem to be able to use localizedString(forCurrencyCode: self.code) to generate the name of the currency in the current locale without being able to get its

Get Currency Symbol based on Country code or Country name using NSLocale

巧了我就是萌 提交于 2019-11-29 02:44:42
I want to display Currency Symbol based on Country name or country code using NSLocale I have all the country name list. suppose I have selected USA then it Return $ Currency Code : NSLocale *locale = [NSLocale currentLocale]; NSString *countryCode = [locale objectForKey: NSLocaleCountryCode]; NSString *country = [locale displayNameForKey: NSLocaleCurrencyCode value: countryCode]; You can build your own list of country codes and that country's currency symbol using the following code: Objective-C: - (void)listCountriesAndCurrencies { NSArray<NSString *> *localeIds = [NSLocale

NSLocale preferredLanguages objectAtIndex:0 always return “en”

◇◆丶佛笑我妖孽 提交于 2019-11-28 22:52:49
Simulator's language already changed to Japanese, why [[NSLocale preferredLanguages] objectAtIndex:0] always return "en" ? Neither preferred language nor region is related to "en", where does "en" come from? Tried to get [[NSLocale preferredLanguages] objectAtIndex: 2 ] , then crash shows *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (2) beyond bounds (1) Does it means there is no any languages are set in simulator? So weird! This never happened before upgrading to Xcode 6.1 with iOS8.1/7.1. Meanwhile, tried same thing on my

How to get NSNumberFormatter currency style from ISOCurrencyCodes?

我的未来我决定 提交于 2019-11-28 12:25:16
If I were to have EUR, or USD (both ISO currency codes), how could I make my NSNumberFormatter to properly format me a string like this? For EUR code: 10.000,00 € For USD code: $10,000.00 I could do this by setting localeIdentifier. But I really need to get it from the ISO currency code. Is this possible? [numberFormatter stringFromNumber: [_property price]]; Thank you! 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

Set default language at first run IOS

喜夏-厌秋 提交于 2019-11-28 08:20:28
问题 I'm trying to set the language for my app at first run. After seeing this question, I decided to do the same. Setting default language for iPhone app on first run I adapted a bit the code, and made this: int main(int argc, char * argv[]) { @autoreleasepool { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:@[[ITConf getStringForKey:ITConfLocale]] forKey:@"AppleLanguages"]; [defaults synchronize]; return UIApplicationMain(argc, argv, nil, NSStringFromClass(

How to get current language code with Swift?

随声附和 提交于 2019-11-28 03:17:31
I want get the language code of the device (en, es...) in my app written with Swift. How can get this? I'm trying this: var preferredLanguages : NSLocale! let pre = preferredLanguages.displayNameForKey(NSLocaleIdentifier, value: preferredLanguages) But this returns nil. Thanks! Vadim Motorine In Swift 3 let langStr = Locale.current.languageCode It's important to make the difference between the App language and the device locale language (The code bellow is in Swift 3 ) Will return the Device language: let locale = NSLocale.current.languageCode Will return the App language: let pre = Locale

NSLocale Swift 3

☆樱花仙子☆ 提交于 2019-11-28 03:07:35
问题 How do I get the currency symbol in Swift 3? public class Currency: NSObject { public let name: String public let code: String public var symbol: String { return NSLocale.currentLocale().displayNameForKey(NSLocaleCurrencySymbol, value: code) ?? "" } // MARK: NSObject public init(name: String, code: String) { self.name = name self.code = code super.init() } } I know NSLocale got renamed to Locale, but displayNameForKey got removed and I only seem to be able to use localizedString

Get Currency Symbol based on Country code or Country name using NSLocale

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 21:58:55
问题 I want to display Currency Symbol based on Country name or country code using NSLocale I have all the country name list. suppose I have selected USA then it Return $ Currency Code : NSLocale *locale = [NSLocale currentLocale]; NSString *countryCode = [locale objectForKey: NSLocaleCountryCode]; NSString *country = [locale displayNameForKey: NSLocaleCurrencyCode value: countryCode]; 回答1: You can build your own list of country codes and that country's currency symbol using the following code:

how to use nsdateformatter to Venezuela

ぐ巨炮叔叔 提交于 2019-11-27 16:29:11
I'm trying to schedule a date on the calendar, which has a start time and an end time, everything works fine if the time zone is in the U.S., and the date the change does not help and I need it to Venezuela what should I do as I place generica, to serve me anywhere no matter the time zone? here I leave the code as data and bring me as I make the date format. comes the date in the following format: 12/10/2012 05:00 pm EKEvent* event = [EKEvent eventWithEventStore:eventStore]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeZone:[NSTimeZone localTimeZone]];