Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

checking if an array doesn't contain a certain object

is there a class available to check if an array doesn't contain an object? I want to do something like

if [(myarray doesntContain @"object")] 

is this possible

like image 460
Alex Stelea Avatar asked Aug 21 '10 10:08

Alex Stelea


People also ask

How do you check if an object is not in an array?

isArray() method is used to check if an object is an array. The Array. isArray() method returns true if an object is an array, otherwise returns false .

How do you check if an array of objects contain a key?

You can iterate through the array, check and see if any of the objects has the key that you are looking for, and return true if it does. If you don't find the key, then the for loop will complete and it will return false.


1 Answers

For NSArray use -containsObject::

if (![myarray containsObject:someObject]) {     // ... } 
like image 124
Georg Fritzsche Avatar answered Oct 18 '22 07:10

Georg Fritzsche