开发者

How to check if an object exists in an NSMutableArray

Is there a method, like containsObject: for NSMUtableArrays 开发者_StackOverflow社区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?


NSMutableArray inherits from NSArray, so all of the NSArray methods work for NSMutableArray.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜