0
votes

Can anyone please tell me why the following code gives the opposite result in a machine with en_US locale identifier ?

if([[[NSLocale currentLocale] localeIdentifier] compare:@"en_US"] == NSOrderedSame)
{NSLog(@"True");} 
else
{NSLog(@"False");}


if([[NSLocale currentLocale] localeIdentifier] == @"en_USR") 
{NSLog(@"TRUE");} 
else    
{NSLog(@"FALSE");}  
1

1 Answers

5
votes
if([[NSLocale currentLocale] localeIdentifier] == @"en_USR") 

This is doing pointer comparison, not string comparison. Perhaps you want -isEqualToString:?