[Solved] Checking whether elements of an Array contains a specified String


NSString has a rangeOfString function that can be used for looking up partial string matches. This function returns NSRange. You can use the location property.

...
  NSArray *qwer = [NSArray arrayWithObjects:@"Apple Juice",@"Apple cake",@"Apple chips",@"Apple wassail"nil];
    for (NSString *name in qwer){
      if ([name rangeOfString:keyword].location == NSNotFound) {
        NSLog(@"contains");
      } 
    }
...

Reference :

  1. https://developer.apple.com/reference/foundation/nsstring/1416849-rangeofstring
  2. https://developer.apple.com/reference/foundation/nsrange

Thanks
Sriram

solved Checking whether elements of an Array contains a specified String