使用 Xcode 5.1.1 在 iOS 中启用和调试 Zombie 对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25994549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable and Debug Zombie objects in iOS using Xcode 5.1.1
提问by Sibir
I have an iOS(7.1) app which crashes due to EXC_BAD_ACCESS
. If I am not wrong, this happens due to the use of an object which is already de-allocated. After a bit of searching, I found out that enabling Zombieobjects help to pin point the line of error. As I am using xcode 5.1.1, I have done the following to Enable Zombie Objects.
我有一个 iOS(7.1) 应用程序,它由于EXC_BAD_ACCESS
. 如果我没有错,这是由于使用了一个已经解除分配的对象。经过一番搜索,我发现启用Zombie对象有助于确定错误线。当我使用 xcode 5.1.1 时,我已完成以下操作以启用 Zombie Objects。
然后,选中
Enable Zombie Objects
Enable Zombie Objects
复选框,然后我去了 Instruments仪器面板,选中Zombies僵尸,点击Profile配置文件并得到了这个,
现在 simulator模拟器(在左侧背景中),其中 a
button
button
和 atextfield
textfield
运行空白,而且我无法理解Instruments仪表盘。What should be the next step? I mean how can I get the lines which are causing the bad access? I am stuck on this for hours but still couldn't find the procedure.
下一步应该怎么做?我的意思是如何获得导致访问错误的线路?我坚持了几个小时,但仍然找不到程序。
Any help is appreciated.
任何帮助表示赞赏。
采纳答案by Mark Szymczyk
Accessing a deallocated object is not the only reason you would get EXC_BAD_ACCESS. Other causes of bad access errors include accessing nil pointers and going past the bounds of an array.
访问释放的对象并不是您获得 EXC_BAD_ACCESS 的唯一原因。其他错误访问错误的原因包括访问 nil 指针和超出数组的边界。
Looking at your screenshots, you are not using a deallocated object. If you were using a deallocated object, the Zombies template in Instruments would let you know. Instruments would show a message similar to the following:
查看您的屏幕截图,您没有使用解除分配的对象。如果您使用的是已释放的对象,Instruments 中的 Zombies 模板会让您知道。Instruments 将显示类似于以下内容的消息:
Your next step should be to set an exception breakpoint in Xcode. When your app crashes, Xcode will pause your app at the point where the crash occurs. To set an exception breakpoint, open the breakpoint navigator by choosing View > Navigators > Show Breakpoint Navigator. Click the + button at the bottom of the navigator and choose Add Exception Breakpoint.
您的下一步应该是在 Xcode 中设置一个异常断点。当您的应用程序崩溃时,Xcode 将在崩溃发生的位置暂停您的应用程序。要设置异常断点,请通过选择 View > Navigators > Show Breakpoint Navigator 打开断点导航器。单击导航器底部的 + 按钮并选择添加异常断点。