Short description of my setup:
There is an SQLObject
base class which has an integer rowId
. it implements isEqual
by comparing its class and its rowId
:
return [self isKindOfClass:[otherObject class]] && self.rowId == otherObject.rowId;
It implements hash by XORing its class with its rowId:
return [[self class] hash] ^ self.rowId;
All objects are stored in an NSMutableSet
so that if they are requested from the DB again, the same object is used rather than creating a new one. When releasing an SQLObject
, it checks if the retainCount
is exactly 1, and if so, removes it from the set, thus deallocating it.
The problem is, it doesn't find the object when it's trying to remove it from the set. The rowId never changes, nor does the class, obviously, so neither the hash nor the isEqual change throughout the object's life. What's going on? Does anybody have any ideas as to why it might not be finding it?
If I change the collection to an NSMutableArray, it does find it.