使用Xcode 5.1.1在iOS中启用和调试Zombie对象 [英] Enable and Debug Zombie objects in iOS using Xcode 5.1.1

查看:115
本文介绍了使用Xcode 5.1.1在iOS中启用和调试Zombie对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iOS(7.1)应用程序因 EXC_BAD_ACCESS 而崩溃。如果我没有错,这是因为使用了已经解除分配的对象。经过一番搜索,我发现启用 Zombie 对象有助于确定错误行。当我使用xcode 5.1.1时,我已完成以下操作启用Zombie Objects

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 Zombie objects 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.



和然后,检查启用Zombie Objects 复选框,



然后我去了到乐器面板,选择 Zombies ,点击个人资料并获得此信息,


Then I went to Instruments panel, selected Zombies,clicked Profile and got this,

< img src =https://i.stack.imgur.com/9jp97.pngalt =iOS模拟器和仪器面板>



现在模拟器(在左侧背景中),它有一个按钮和一个 textfield 正在运行空白,我也无法理解仪器面板上的任何内容。


Now the simulator (in the left background), which had a button and a textfield is running blank and also I can't understand anything on the Instruments panel.

下一步应该是什么?我是说如何获得导致访问不良的线路?我被困在这几个小时但仍无法找到程序。

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.

任何帮助都表示赞赏。

推荐答案

访问解除分配的对象并不是获得EXC_BAD_ACCESS的唯一原因。导致错误访问错误的其他原因包括访问nil指针并越过数组的边界。

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.

查看截图,您没有使用解除分配的对象。如果您使用的是已释放的对象,则Instruments中的Zombies模板会通知您。仪器将显示类似于以下内容的消息:

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:

下一步应该是在Xcode中设置一个异常断点。当您的应用崩溃时,Xcode会在崩溃发生时暂停您的应用。要设置异常断点,请选择视图>导航器>显示断点导航器以打开断点导航器。单击导航器底部的+按钮,然后选择Add Exception Breakpoint。

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 5.1.1在iOS中启用和调试Zombie对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆