Reputation: 32986
Is there a method, like containsObject: for NSMUtableArrays to check if an object exists in there without having to loop through the whole array and check each element? What's the best way to check if an object exists in an NSMutableArray?
Upvotes: 1
Views: 1960
Reputation: 410592
If you're mostly using an array to check if an object exists, and you're using unique elements, you may want to use an NSSet
. Checking a set for membership is faster than checking an array.
Upvotes: 4
Reputation: 8448
NSMutableArray
inherits from NSArray
, so all of the NSArray
methods work for NSMutableArray
.
Upvotes: 12