How to check if a String contains another String in Objective C?

September 22, 2011

Answer

NSString *haystack = @”welcome to the mall”;

NSString *needle = @”mall”;

if ([haystack rangeOfString:needle].location == NSNotFound)

NSLog(@”needle not found in haystack”);}

else

{

  NSLog(@”needle found in haystack.”);

}

How to do Case Insensitive comparison in Objective C?How to encode URL String using ISO Latin Encoding?
Sponsors
Like us on Facebook