如果你想知道字符串内的某处是否包含其他字符串,使用rangeOfString: 方法
-(NSRange)rangeOfString :(NSString *)aString;
1 NSString *num = @"sdhfdsjkljg"; 2 3 NSRange a =[num rangeOfString:@"hf"]; 4 NSLog(@"%@",NSStringFromRange(a)); 5 //输出{2, 2}
NSStringFromRange :Returns a string representation of a range
原文地址:http://www.cnblogs.com/limicheng/p/3826221.html