We have a bunch of NSManagedObjects of various types. Some of them have members that are NSSet's of other NSManagedObjects. The problem is that I really need to override the hash and isEquals methods of the objects that are IN the set - but they are NSManagedObjects. I'm having problems with getting multiple identical objects in the set. As far as I can tell, since hash defaults to the object address - all objects are different. So I need to override hash and isEquals - but can't see any way to do it.
What we have is a bunch of stuff in the System, and more comes in via XML - sometimes repeats of the existing objects. When they are the same, I don't want dups added to the set.
As mentioned above by Wain, NSManagedObject documentation states that you must not override hash
or isEqual:
. So this means a stock NSSet
does not do what you need.
Some of your options are:
NSSet
contents to identify and remove duplicatesNSManagedObjects
that will return the same object when given the same inputsNSManagedObjects
hash
and isEqual:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With