Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does NSSet's containsObject: test for pointer equality or value equality?

Say I have an NSSet with a string in it. If I send containsObject: with another string which is a different pointer but the exact same string value, will that return YES?

Also, is it the same story when it comes to removeObject:? I.e., different objects with different pointers but the same string values will cause removal?

like image 341
Chris Avatar asked Dec 07 '11 05:12

Chris


1 Answers

-containsObject: uses -isEqual: (and -hash) for equality testing. This applies to -removeObject: as well, and any other operations in NSSet that depend on some notion of equality.

like image 52
Lily Ballard Avatar answered Sep 22 '22 18:09

Lily Ballard