Check for item in array without looping

cocoa, objective-c

Solution

Use `-[NSArray containsObject:]`.

(You don't have to write the loop yourself, but of course NSArray almost certainly has to use a loop internally.)

if ([array containsObject:string])
    NSLog(@"Yes, the array contains my string.")

Problem

I have an array and I want to check if one string is in the array, without looping. Just using "if's" I know if some string exists or not in the array. Is there any possibility?

Original source