2
如何提取NSUInteger index
從Objective-C的精華指數:
NSRange range = [string rangeOfString: substring]
,所以我可以在[array objectAtIndex:index]
寫這個指標?如果子在該字符串的開頭方式發現
如何提取NSUInteger index
從Objective-C的精華指數:
NSRange range = [string rangeOfString: substring]
,所以我可以在[array objectAtIndex:index]
寫這個指標?如果子在該字符串的開頭方式發現
// make sure that the substring was actually found:
NSRange result = [string rangeOfString:substring];
if (result.location != NSNotFound)
{
// make sure that the index exists in the array
if (result.location < [array count])
{
id someObj = [array objectAtIndex:result.location];
// do something cool with someObj here
}
}
NSRange range = [string rangeOfString:substring];
NSUInteger index = range.location;
//...
range.location返回一個非常大的數字。爲什麼是這樣? – coolcool1994
@ coolcool1994你找到原因了嗎?我有同樣的問題 – hoangpx