Ios 与#x2013;NSLocale类中的displayNameForKey:value:和-objectForKey:
大家好,我只是简单地问一下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
您可以使用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);
将产生以下输出:
法语区域在法语中称为“法语(法国)”英语中的法语区域称为“法语(法国)” 这本书中有很多例子