Your feedback is appreciated..Send Feedback Thank You.

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

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.”);

}

Subscribe to DeveloperFeedDid you like this article? Did it Help you Solve your Problem? You can get the all the latest articles published at DeveloperFeed in your email inbox by entering your email address below. Your address will only be used for mailing you the articles, and each one will include a link so you can unsubscribe at any time.