Reputation: 3931
If I have an array of strings, can I reliably test if it contains a given string with NSArray containsObject
- or should I loop through and test isEqualToString on each object?
Upvotes: 0
Views: 103
Reputation: 15015
Yes you can use containsObject method as well which is internally calls isequal method only.
Upvotes: 0
Reputation: 18253
containsObject:
uses isEqual:
, which is reliable and tests for equality, i.e., if the object in the array and the parameter are really equal. It might actually call isEqualToString:
under the hood.
Upvotes: 5