Search code examples
objective-ciosxcodenszombie

NSZombies: Identify Exact Object In Code?


In short, I'm an NSZombies noob. I JUST started trying to use them to debug with because, until now, I've been able to resolve all of my memory issues without them.

Right now, I'm getting...

[UIImage isKindOfClass:]: message sent to deallocated instance 0x8095f10

Is there a way to make that point to a line in my code? I mean, it's a big improvement over just getting a crash/bad access error, but that still only narrows it down to some sort of UIImage memory issue. Ideally, I would like it to say "the UIImage you created on line x of your y class was sent a isKindOfClass message after being deallocated."

Also, I'm pretty sure nowhere in my code am I using sending isKindOfClass to a UIImage in the first place. Does UIImage use that method somewhere inside its code?

edit: Updated tags. Accidentally had tags from an old question.


Solution

  • Run your app in the iOS simulator using Instruments and select the Zombie option.

    Recreate the conditions that cause your issue and then you should be able to look at a reverse stack trace with system symbols hidden and it will take you right to the place in your code where the zombie was referenced. It might not tell you where it got deallocated, but it will certainly help you narrow down the scope of the error.