Search code examples
objective-cmemory-managementdeallocretaincount

How to identify who is referencing an object in objective C?


Is there any way to find, who is referencing an object in objective C?

I have a scenario where I'm expecting an object to have retain count as zero but is is greater than zero. I have no clue at that point what other objects are referencing it. I might have missed somewhere to remove reference, If there is any way to find it out I can take care of de-referencing those objects.

I'll appreciate any help in this regard.


Solution

  • Not directly, no. You can use Clang's static analyzer (available as the "Analyze" build option in Xcode); it may be able to detect the places where you failed to free an object.