问题
I am having some wired crash in my iOS app and its not 100% reproducible. From crash log I can see that unrecognized selector(property accessor) is sent to object that is not of correct type (most likely zombie). Is there anyway in XCode that I can used to see if I am trying to access zombie object ?
Thanks.
回答1:
There are two ways. 1. Go to breakpoints sections on the left of XCode, down you can see an option to add exception breakpoints. 2. Click Menubar > Product > Scheme > Edit Scheme select the "Diagnostics" tab and click "Enable Zombie Objects"
Hope it helps :)
回答2:
There are several ways. You can turn on zombies by setting the "Enable Zombie Objects" checkbox to true in the diagnostics tab of your current build scheme's run item.
You can run the Zombies instrument on your app in the Instruments tool (select "profile" from the project menu, then in the resulting dialog, select the Memory group of instruments, and look for a "Zombies" instrument. This is really just the allocations tool with instruments turned on.
When you turn on zombie monitoring using either approach, the system no longer frees objects that are deallocated. instead they are marked with a special signature that indicates that they are a zombie. Then the next time you try to reference one you get an immediate, very specific crash, and the system can still tell what kind of object it was before it became a zombie, and with Instruments you can even tell where in your program it was allocated.
来源:https://stackoverflow.com/questions/20534018/how-to-track-down-zombie-object-crash