Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 更改NSDate工作日和月份的语言_Ios_Objective C_Nsdate_Nsdateformatter_Nstimezone - Fatal编程技术网

Ios 更改NSDate工作日和月份的语言

Ios 更改NSDate工作日和月份的语言,ios,objective-c,nsdate,nsdateformatter,nstimezone,Ios,Objective C,Nsdate,Nsdateformatter,Nstimezone,我想显示这样的日期:工作日7个月。 我这样做了,我有正确的语法 NSDateFormatter* df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"EEEE dd MMMM"]; [df setTimeZone:[NSTimeZone localTimeZone]]; 记录的结果是:3月16日星期六。我只想要法国的约会,不是英国的。我试图设置本地时区,但它没有改变什么。您知道如何执行此操作吗?您可以使用适当的NSLocale对象设

我想显示这样的日期:工作日7个月。 我这样做了,我有正确的语法

NSDateFormatter* df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"EEEE dd MMMM"];
[df setTimeZone:[NSTimeZone localTimeZone]];

记录的结果是:3月16日星期六。我只想要法国的约会,不是英国的。我试图设置本地时区,但它没有改变什么。您知道如何执行此操作吗?

您可以使用适当的
NSLocale
对象设置日期格式化程序的区域设置


另外,要小心像这样硬编码的日期格式。您的用户可能不喜欢以该格式查看日期,因此您应该首先通过
+[NSDateFormatter dateFormatFromTemplate:options:locale::
运行格式字符串。WWDC 2012会议“国际化提示和技巧”中有一系列关于此的有用信息。

使用标识符初始化区域设置。 您可以从中获取所有可用的标识符

[NSLocale availableLocaleIdentifiers];
我相信,"fr_BI"是法国的一种标识

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_BI"];
[dateFormatter setLocale:locale];

要选择适当的法语标识符,请使用下面的代码:NSArray*bb=[NSLocale availableLocaleIdentifiers];NSPredicate*bPredicate=[NSPredicate PREDITEWITHFORMAT:@“从[c]“fr”开始的自我”;NSArray*beginWithFr=[bb FilteredarrayingPredicate:BPPredicate];对于(NSString*elt in beginWithFr){NSLog(@“%@:%@”,elt,[[NSLocale alloc]initwithlocaleidentier:elt]localizedstringforlocaleidentier:elt]);}