Dim*_*_Al 0 objective-c nslocale
任何人都可以告诉我为什么以下代码在具有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");}
Run Code Online (Sandbox Code Playgroud)
if([[NSLocale currentLocale] localeIdentifier] == @"en_USR")
Run Code Online (Sandbox Code Playgroud)
这是做指针比较,而不是字符串比较.也许你想要-isEqualToString:?
| 归档时间: |
|
| 查看次数: |
3828 次 |
| 最近记录: |