-
NSString *str;
-
-
str = [NSString stringWithFormat:@"This is %@","John"];
-
NSLog(@"str--->%@",str);
-
-
NSLog(@"The length of this string is %@",[str length]);
-
-
BOOL isequal = [str isEqualToString:@"this is John"];
-
-
-
-
-
-
-
-
int result = [@"bool" compare:@"cool"];
-
NSLog(@"The result is %d",result);
-
-
-
-
-
-
int result1 = [@"This is John" compare:@"this is John" options:NSCaseInsensitiveSearch | NSNumericSearch];
-
NSLog(@"The result is %d",result1);
-
-
-
BOOL isHas = [str hasPrefix:@"This"];
-
-
BOOL isHas = [str hasSuffix:@"John"];
-
-
-
NSRange range = [str rangeOfString:@"is" options:NSCaseInsensitiveSearch];
-
NSLog(@"The location in the string named ‘str‘ of ‘is‘ is @d",range.location);
ios 不区分字符串大小写的比较
原文:http://blog.csdn.net/yangchen9931/article/details/45099901