NSString *str1=[[NSString alloc]initWithString:@"aaa"];
NSString *str2=[[NSString alloc]initWithString:@"bbb"];
//比较字符串对象是否相同:
/*if([str1 isEqualToString:str2])
{
NSLog(@"两个字符串相同");
}else{
NSLog(@"两个字符串不相同");
}*/
//比较字符串对象大小:
NSComparisonResult result=[str1 compare:str2];
//compare相同于caseInsensitiveCompare
if (result==NSOrderedAscending)
{
NSLog(@"str1<str2");
}else if (result==NSOrderedDescending)
{
NSLog(@"str1>str2");
}else if (result==NSOrderedSame)
{
NSLog(@"str1=str2");
}