如何从中NSUInteger index
提取
NSRange range = [string rangeOfString: substring]
所以我可以写这个索引[array objectAtIndex:index]
?
如何从中NSUInteger index
提取
NSRange range = [string rangeOfString: substring]
所以我可以写这个索引[array objectAtIndex:index]
?
NSRange range = [string rangeOfString:substring];
NSUInteger index = range.location;
//...
// 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
}
}