iosnssetnscountedset

NSSet & NSCountedSet object differentiation


I am working with NSSet and NSCountedSet and I have a question about how NSSet differentiate the object? Is it using the memory location? If I had 2 objects named car1 and I got the one from an array and the other downloaded from Internet will be considered as one object if are exact the same? Going through Apple's documentation didn't explained the above case.


Solution

  • NSSet use hash and isEqual method to determine objects equality. If you didn't override this two methods Foundation will use methods from NSObject. Mike Ash has a good article about hash and isEqual.