I have a small confusion in my application.
How can I check whether an object was released or not in iPhone?
I have a small confusion in my application.
How can I check whether an object was released or not in iPhone?
Sorry, but you're trying to solve the wrong problem.
If you follow some simple rules there is absolutely no need "find out" whether an object has been released or not; you will know.
The simple rules are:
Do not use retainCount
. If the object has been deallocated (i.e., its retain count is zero), then you can't perform any operations on the object since it no longer exists! Also, even if it's currently one, what's to say that it's not in the autorelease pool and will be zero the next time you look?
If object was released then you cannot access its properties.
You can use Profiler (NSZombies) to detect which objects were released and then accessed.
any message to the object when zombies are enabled will suffice. if the program crashes because you messaged a zombie, then you know!
if you have enabled reference count tracking in instruments, then you can see each frame of each ref count event and find out where the invalid ref count offset has been introduced.