我有一個有趣的小問題。所以,我需要創建一個if語句,可以檢測,如果有一個字後一個字一個數組檢查一個單詞後面是否有單詞(NSSTRING)
所以我的代碼是
NSArray *words = [texfield.text componentsSeparatedByString:@" "];
int index = [words indexOfObject:@"string"];
我不知道如果我要像做
NSString*needle=words[index+1];
if (needle isEqualto @"") {
//There is a word after @"string";
}
我應該怎麼辦?
我怎麼能確定是有後@「串」字?
我感謝所有幫助! :)