NSSTRING INDEXOF IN OBJECTIVE-C

Mikki Halpin

Total Post:23

Points:161
Posted by  Mikki Halpin
 1604  View(s)
Ratings:
Rate this:

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

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: NSString indexOf in Objective-C

    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)

    //using
    NSString a = @"PUC MINAS - BRAZIL";

    NSString b = @"BRAZIL";

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!