0

I have NSArray and I want to remove duplicates from it. I know that using this method [NSSet setWithArray:[arrAllValues valueForKey:@"value"]] I also know that it invokes method specified in valueForKey parameter. But I don't know what method NSSet invokes to compare objects in array. My problem is that I want to compare property named "value", but I want to return array of the object that contains the property and not the property. Can I do that?

Thanks !!!

NetDeveloper
  • 509
  • 1
  • 9
  • 20
  • Please refer this question: http://stackoverflow.com/questions/1025674/the-best-way-to-remove-duplicate-values-from-nsmutablearray-in-objective-c – vadivelu Mar 23 '12 at 13:48

1 Answers1

1

It compares them using the NSObject protocol reference method:

- (BOOL)isEqual:(id)anObject

therefore, you can override this method in your class to implement the desired behavior, as a note just like you would do it in Java, you should also override hash.

Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118