What is the diference between these two methods belonging to the NSSet class:
-(BOOL)containsObject:(id)anObject
-(id)member:(id)object
The answer lies in the return values. containsObject returns a YES or a NO depending on if the object you send belongs to that particular set.
member returns id, which means that it returns the actual object if that object is part of the set.
As an example, you have an NSSet, aSet, with anObject. anObject belongs to the set.
[aSet containsObject:anObject]; //returns YES
[aSet member:anObject]; //If the set contains an object equal to object (as determined by isEqual:) then that object (typically this will be object), otherwise nil.
If anObject does not exist in aSet:
[aSet containsObject:anObject]; //return NO
[aSet member:anObject]; //return nil
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