我想这样做:
while(theString (does not have) @"this string" (in it)) {
do something
}
答案 0 :(得分:4)
来自this stackoverflow帖子:
NSString *string = @"hello bla bla";
if ([string rangeOfString:@"bla"].location == NSNotFound) {
NSLog(@"string does not contain bla");
} else {
NSLog(@"string contains bla!");
}
关键是要注意到这一点 rangeOfString:返回NSRange struct,而documentation说 它返回结构 如果“干草堆”有,
{NSNotFound, 0}
不包含“针”。