JoshDG
JoshDG

Reputation: 3931

Index of object equal to string

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

Answers (2)

Hussain Shabbir
Hussain Shabbir

Reputation: 15015

Yes you can use containsObject method as well which is internally calls isequal method only.

Upvotes: 0

Monolo
Monolo

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

Related Questions