In Objective-C, is there any way to find out which objects are the ones retaining another object?
For example, I have a collection of MyClass objects and if I iterate through them to get the retain count on each object, I see the count at 2. How can I find out who the holders are?
for (NSString *aKey in aDictionaryOfMyObjects)
{
MyClassObject *myClassObj = [aDictionaryOfMyObjects objectForKey:aKey];
// following shows a retain count of 2. Presumably, the first count is
// due to myClassObj is held as the value in NSDictionary and second is because I
// I just acquired a pointer to it above. I'd like to find out who exactly
// might have references to myClassObj.
NSLog(@"retain count = %d", [myClassObj retainCount]);
}