How might I check if a particular NSString is present in an NSArray?

Ravi picture Ravi · Sep 13, 2011 · Viewed 16k times · Source

How might I check if a particular NSString is presnet in an NSArray?

Answer

Janak Nirmal picture Janak Nirmal · Sep 13, 2011

You can do it like,

NSArray* yourArray = [NSArray arrayWithObjects: @"Str1", @"Str2", @"Str3", nil];
if ( [yourArray containsObject: yourStringToFind] ) {
    // do found
} else {
    // do not found
}