How might I check if a particular NSString is present in an NSArray?
问题 How might I check if a particular NSString is presnet in an NSArray? 回答1: You can do it like, NSArray* yourArray = [NSArray arrayWithObjects: @"Str1", @"Str2", @"Str3", nil]; if ( [yourArray containsObject: yourStringToFind] ) { // do found } else { // do not found } 回答2: Iterating or containsObject are order n ways to find. If you want constant time lookup, you can also maintain a hash table like NSSet or NSHashTable but that increases space but saves time. NSArray* strings = [NSArray