NSString listOfNames = @"..."; // a long list of names
NSString name = @"Ward";
NSRange match = [listOfNames rangeOfString:name];
if (match.location == NSNotFound) {
NSLog(@"No match found!");
// Other actions to be taken
} else {
NSLog(@"Match found!");
// Other actions to be taken
}
why didn’t we add asterisk sign on the code in line 1,2 and 3.
like this
ibex10 nailed it, but it’s also worth pointing out that NSString is the name of a class, whose instances live on the heap, meaning that we must use pointers any time we’re dealing with them. NSRange is the name of a struct, whose instances live on the stack, and as such, we don’t tend to use pointers to them.