谁能告诉我为什么下面的代码在一台使用en_US语言环境标识符的机器上会产生相反的结果?
if([[[NSLocale currentLocale] localeIdentifier] compare:@"en_US"] == NSOrderedSame)
{NSLog(@"True");}
else
{NSLog(@"False");}
if([[NSLocale currentLocale] localeIdentifier] == @"en_USR")
{NSLog(@"TRUE");}
else
{NSLog(@"FALSE");} 发布于 2011-06-23 04:22:40
if([[NSLocale currentLocale] localeIdentifier] == @"en_USR") 这是进行指针比较,而不是字符串比较。也许你想要-isEqualToString:
https://stackoverflow.com/questions/6446048
复制相似问题