is there a class available to check if an array doesnt contain an object? i want to do something like
if [(myarray doesntContain @"object")]
is this possible thanks
is there a class available to check if an array doesnt contain an object? i want to do something like
if [(myarray doesntContain @"object")]
is this possible thanks
If you're dealing with an NSArray, your first port of call should probably be the Apple documentation for NSArray, and probably the method containsObject, there's an example in this question.
For NSArray
use -containsObject:
:
if (![myarray containsObject:someObject]) {
// ...
}
Use this:
if ([myarray indexOfObject:someObject] != NSNotFound) { // Or containsObject:someObject (as mentioned by Georg)
[myarray addObject:someObject];
}