How to find out a specific character is present in a NSString or not?
Try this:
NSRange range = [country rangeOfString:searchtext];if (range.location != NSNotFound){}
You also have the position (location) and length of your match (uninteresting in this case but might be interesting in others) in your range object. Note that searchtext
must not be nil
. If you are only interested in matching (and not the location) you can even condense this into
if ([country rangeOfString:searchtext].location != NSNotFound){}