Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.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 与#x2013;NSLocale类中的displayNameForKey:value:和-objectForKey:_Ios_Nslocale - Fatal编程技术网

Ios 与#x2013;NSLocale类中的displayNameForKey:value:和-objectForKey:

Ios 与#x2013;NSLocale类中的displayNameForKey:value:和-objectForKey:,ios,nslocale,Ios,Nslocale,大家好,我只是简单地问一下NSLocale类中–displayNameForKey:value:和-objectForKey:之间的区别是什么?我在网上搜索了一下,但没有找到。多谢各位 您可以使用displayNameForKey:value:根据正在调用的区域设置对象获取适合显示的标签。例如: NSLocale *french = [[[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"] autorelease]; NSString *fre

大家好,我只是简单地问一下NSLocale类中–displayNameForKey:value:和-objectForKey:之间的区别是什么?我在网上搜索了一下,但没有找到。多谢各位


您可以使用displayNameForKey:value:根据正在调用的区域设置对象获取适合显示的标签。例如:

NSLocale *french = [[[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"] autorelease];
NSString *frenchName = [french displayNameForKey:NSLocaleIdentifier value:@"fr_FR"];

NSLocale *english = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
NSString *englishName = [english  displayNameForKey:NSLocaleIdentifier value:@"fr_FR"];

NSLog(@"French locale in French is called '%@'", frenchName);
NSLog(@"French locale in English is called '%@'", englishName);
将产生以下输出:

法语区域在法语中称为“法语(法国)”
英语中的法语区域称为“法语(法国)”


在中有很多示例。

您使用displayNameForKey:value:根据您调用的区域设置对象获取适合显示的标签。例如:

NSLocale *french = [[[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"] autorelease];
NSString *frenchName = [french displayNameForKey:NSLocaleIdentifier value:@"fr_FR"];

NSLocale *english = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
NSString *englishName = [english  displayNameForKey:NSLocaleIdentifier value:@"fr_FR"];

NSLog(@"French locale in French is called '%@'", frenchName);
NSLog(@"French locale in English is called '%@'", englishName);
将产生以下输出:

法语区域在法语中称为“法语(法国)”
英语中的法语区域称为“法语(法国)”

这本书中有很多例子