nslocale

NSLocale currency symbol, show before or after amount value

假装没事ソ 提交于 2019-12-21 04:03:41
问题 I am using StoreKit to implement an in app purchase store in my application. I have a custom design and it means that the value of the price should be white and large, and the currency symbol smaller, darker and aligned to the top of the price value. I can get the currency symbol without any problems by using the NSLocale in SKproduct 's priceLocale property, and the value of the price in the price property. My problem is knowing when I should put the currency symbol before the price and when

NSDateformatter setDateFormat according to currentLocale

拟墨画扇 提交于 2019-12-21 03:55:23
问题 I'm going mad with, probably, a stupid problem. I have 3 strings: year, month and day. I need to have a date in the right format based on currentLocale, so i.e. if currentLocale localeIdentifier is en_US my dateFormat should be: MMM/dd/yyyy if it's fr_FR the dateFormat should be dd/MMM/yyyy I don't think the only way to do this is to get currentLocale localeIdentifier and start with a bunch of if then. Thanks in advance. Max 回答1: Look at NSDateComponents to create an NSDate, then use

Swift - Get list of countries

。_饼干妹妹 提交于 2019-12-20 10:53:59
问题 How can I get an array with all countries names in Swift? I've tried to convert the code I had in Objective-C, which was this: if (!pickerCountriesIsShown) { NSMutableArray *countries = [NSMutableArray arrayWithCapacity: [[NSLocale ISOCountryCodes] count]]; for (NSString *countryCode in [NSLocale ISOCountryCodes]) { NSString *identifier = [NSLocale localeIdentifierFromComponents: [NSDictionary dictionaryWithObject: countryCode forKey: NSLocaleCountryCode]]; NSString *country = [[NSLocale

NSLocale returning wrong value in iOS 11

爱⌒轻易说出口 提交于 2019-12-19 03:24:19
问题 Starting from iOS 11.0, the following code returns "de_US" instead of "en_US" : // => Returns "de_US" NSString *regionCode = [[NSLocale currentLocale] objectForKey:NSLocaleIdentifier]; NSLog(@"Region code: %@", regionCode); Below iOS 11, it returns "en_US". My device has for language and region English / United States. Preferred languages (despite I do not use them in my code) are in order: English Deutsch French Is it a known issue of iOS 11? Has the API changed? 回答1: Found it! It's a change

How to get country code using NSLocale in Swift 3

微笑、不失礼 提交于 2019-12-17 22:22:02
问题 Could you please help on how to get country code using NSLocale in Swift 3 ? This is the previous code I have been using. NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String I can get Language Code as below in Swift 3. Locale.current.languageCode! As I can see, fetching languageCode is straight forward but countryCode property is not available. 回答1: See Wojciech N.'s answer for a simpler solution! Similarly as in NSLocale Swift 3, you have to cast the overlay type Locale

Get country code from country name in IOS

十年热恋 提交于 2019-12-17 10:44:50
问题 Im retrieving a country name from a server in english. For example, "Spain" What I want to do is, assuming the country name is going to be written in english, get the country code. What should I do? I´ve found getting the country name from the country code quite easy, but I´ve got no idea of how to do the opposite operation. Thanks a lot. 回答1: Jef's answer helped here, with slight additions. NSArray *countryCodes = [NSLocale ISOCountryCodes]; NSMutableArray *countries = [NSMutableArray

How to map MCC + MNC to users phone country code in iOS objective-C without using Location info?

荒凉一梦 提交于 2019-12-13 12:32:42
问题 I want the actual country code of the users phone number without prompting the user for Location Permission. How do I get it? Here is the code I use to get the MCC and MNC CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = [networkInfo subscriberCellularProvider]; NSString *mcc = [carrier mobileCountryCode]; NSString *mnc = [carrier mobileNetworkCode]; I get MCC - 310 and MNC - 410 which corresponds to AT&T USA. But what I want is '+1' the

How to refresh the NSLocale in iPhone?

筅森魡賤 提交于 2019-12-12 14:44:29
问题 I am currently working in iPhone application, Using NSLocale to get the current Currency symbol working fine, but when i press home button the app goes to background process and i change the Currency (Setting>>International>>Regionformat>>Like United states,India etc...) in this way, then open that application from background the currency symbol not changed, but i navigate to another screen then comes to previous screen only currency changed, but i want when i open the application from

Iphone, Obtaining a List of countries from MonoTouch

守給你的承諾、 提交于 2019-12-11 13:22:10
问题 Is it possible to replicate what the code in here does in MonoTouch? Here is what I've tried so far: foreach(string countryCode in NSLocale.ISOCountryCodes){ // How to convert this objective-c code to c#? // [[NSLocale currentLocale] displayNameForKey:NSLocaleCountryCode value:countryCode] } 回答1: Sadly a quick look shows that displayNameForKey:value: to be (currently as of 4.2.x) missing from MonoTouch (and MonoMac) bindings. I'll look into implementing it and will update this entry once done

Convert DateTime from English to Spanish in iPhone?

℡╲_俬逩灬. 提交于 2019-12-11 06:32:42
问题 Does anybody know how to convert a DateTime from English to Spanish? E.g convert: December 07, 10:42AM into Diciembre 07, 10:42AM Please help me. How to convert this? Thanks in advance. I tried this: NSLocale *frLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es"] autorelease]; NSLog(@"%@", [frLocale displayNameForKey:NSLocaleIdentifier value:@"December 07, 10:42AM"]); // Value comes Null 回答1: Try like below it will help NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];