[NSArray containsObject] use isEqual. isEqual default to the address.
Say I want to know if [NSArray containsObject] based on reference? So I want to know whether that actual object, rather than an object eQual to it, is in the array.
I want to use it for to compare core data objects. Core data objects may be deleted and dereferenced and I wonder what happen to all array that contain elements that reference it.
And in that case, is there a problem?
It sounds like you want to store objects where
isEqualdoes not use the address, but still use the address for this check, right?There’s no
-[containsObjectIdenticalTo:], but there is an-[indexOfObjectIdenticalTo:]; if that returns anything but NSNotFound, it’s contained.As the NSArray reference docs make clear:
There’s a whole family of
Identicalmethods onNSArrayand other collections, that are there exactly for this purpose.