2010-08-09 58 views

回答

4

this計算器後:

NSString *string = @"hello bla bla"; 
if ([string rangeOfString:@"bla"].location == NSNotFound) { 
    NSLog(@"string does not contain bla"); 
} else { 
    NSLog(@"string contains bla!"); 
} 

的關鍵是注意到, rangeOfString:返回一個NSRange 結構體,並且documentation說 它返回結構體 {NSNotFound, 0}如果「ha ystack「確實 不包含」針「。

+0

+1鏈接到文檔 – 2010-08-09 19:18:26

+0

謝謝你的+1,但請注意,我的文章是對同一個問題的另一個答案的引用 - 原始海報真的比我更值得! – Stephen 2010-08-09 19:27:31

相關問題