Home > DeveloperSection > Forums > NSString indexOf in Objective-C
Mikki Halpin
Mikki Halpin

Total Post:23

Posted on    September-07-2015 12:09 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 1007  View(s)
Rate this:

Are there anything similar to an indexOf function in the NSString objects?

Tarun Kumar

Total Post:210

Posted on    September-08-2015 1:19 AM

If you want just know when String a contains String b use my way to do this.
#define contains(str1, str2) ([str1 rangeOfString: str2 ].location != NSNotFound)

NSString a = @"PUC MINAS - BRAZIL";

NSString b = @"BRAZIL";

if( contains(a,b) ){
    //TO DO HERE

Don't want to miss updates? Please click the below button!

Follow MindStick