nslocale

How do I get a list of countries in Swift ios?

余生颓废 提交于 2020-01-01 03:59:05
问题 I've already seen two similar questions to mine, but the answers for those questions do not work for me. I have an old project with a list of countries manually typed out inside a set of square brackets. I can easily use this in my pickerView but I'm wondering if there is a more efficient way to do this? I will be using the list of countries in a UIPickerView. 回答1: You can get a list of countries using the NSLocale class's isoCountryCodes which returns an array of [String] . From there, you

How to reduce the amount of currency codes you get back from NSLocale.Key.currencyCode

时光怂恿深爱的人放手 提交于 2019-12-25 18:41:36
问题 I have an ios app that I'm trying to allow the users to select which currency they want to use. Right now I have the full list of currencies but there seem to be some duplicates there such as: Is there a way to filter out the others? The dollar isn't the only one with multiples some have date ranges listed with them. I'm sure there is some built-in method that does this, but my searching so far hasn't pointed me in the right direction. Here is what I am doing: let locale = NSLocale.current as

NSDateFormatter dateFromString for 24hr date gives wrong time

我只是一个虾纸丫 提交于 2019-12-24 23:40:26
问题 I want to add event to native calender.I am having problem in getting date accurate time from string. I have set locale,24 hr format. but still getting the same bug. EKEvent *event = [EKEvent eventWithEventStore:self.eventStore]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSLocale *locale =[[[NSLocalealloc]initWithLocaleIdentifier:@"en_US_POSIX"]autorelease]; [dateFormatter setLocale:locale]; [dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm"]; event.startDate=

Swift NSLocale Simulator iOS 8

狂风中的少年 提交于 2019-12-24 13:25:12
问题 I'm having an issue with Swift and the iOS 8 Emulator in XCode 6.1. Indeed when I try to use NSLocale, almost every functions of it return nil. Here is how I use it: let cc = "fr" // Example let locale = NSLocale.currentLocale() let countryName = locale.displayNameForKey(NSLocaleCountryCode, value : cc) println(countryName) // Shows : nil It does work on device, iOS 7 and iOS 8 and on simulator iOS 7. It doesn't work on simulator iOS 8 and on Playground, it even EXC_BAD_ACCESS. I guess it's

Changing locale of UIDatePicker in Countdown Timer mode

╄→гoц情女王★ 提交于 2019-12-24 09:21:04
问题 I have UIDatePicker in CountdownTimer mode and need to change the wording of hours and min to German locale. I tried both, to set locale to German (Germany) in storyboard and in code, but both failed and the app still shows default english words for hours and min . timePicker.locale = Locale(identifier: "de") When I configure locale on UIDatePicker in Date and Time mode, it correctly respects German locale and displays the date in german format. Any idea why locale does not change in

How can i get the locale from currency names list

限于喜欢 提交于 2019-12-24 04:31:41
问题 i am making a currency selecting screen.for that i am displaying the list of currencies using the following code to create an array of currencies from which a tableview is populated NSArray *countryArray = [NSLocale ISOCurrencyCodes]; for(NSString *country in countryArray) { //NSLog(@"%@",[[NSLocale currentLocale] displayNameForKey:NSLocaleCurrencyCode value:country]); if([[NSLocale currentLocale] displayNameForKey:NSLocaleCurrencyCode value:country]) { [countriesArray addObject:[[NSLocale

How can I find out whether an NSDate is a business day?

耗尽温柔 提交于 2019-12-24 01:51:04
问题 How can I find out whether an NSDate is a business day? That is to say, whether or not it is a weekend according to the user's current locale and calendar settings - so not hardcoded to just be Monday to Friday? NSCalendar has a firstWeekday property, but that just seems to be a presentational thing; it's Sunday in the US and Monday in the UK. EDIT: I'm not worried about holidays, I just want to be able to shade the weekends of a calendar in the same way as the built-in calendar app. 回答1:

NSLocaleCountryCode returns nil

China☆狼群 提交于 2019-12-23 07:28:58
问题 I have a bugreport that states a crash in the following line, where client is an instance of NSMutableDictionary [client setObject:[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode] forKey:@"country"]; My guess is, that NSLocaleCountryCode returns nil in this line, which leads to adding a nil object to an NSDictionary which would lead to a crash. The question is, has anybody experienced an issue like this before? Are there any reasons NSLocaleCountryCode could be nil for the

NSLocaleCountryCode returns nil

给你一囗甜甜゛ 提交于 2019-12-23 07:28:10
问题 I have a bugreport that states a crash in the following line, where client is an instance of NSMutableDictionary [client setObject:[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode] forKey:@"country"]; My guess is, that NSLocaleCountryCode returns nil in this line, which leads to adding a nil object to an NSDictionary which would lead to a crash. The question is, has anybody experienced an issue like this before? Are there any reasons NSLocaleCountryCode could be nil for the

Display currency symbols using currency codes in iPhone SDK

て烟熏妆下的殇ゞ 提交于 2019-12-22 00:52:50
问题 Actually, I want to display the currency symbols of all currency codes and I'm using code like this,but i only get "$" symbols -(void) showCurrenciesList { NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; [numFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; //[numFormatter setLocale: [NSLocale currentLocale]]; NSMutableArray *aryAllCurrencies = [[NSMutableArray alloc] init]; //NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier: @"en_US"] autorelease];