使用ARC的EXC_BAD_ACCESS,无法在模拟器上跟踪 [英] EXC_BAD_ACCESS using ARC and can't track on simulator

查看:96
本文介绍了使用ARC的EXC_BAD_ACCESS,无法在模拟器上跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为客户端构建应用程序,一切进展顺利,直到我开始遇到此错误.这是一种独特的情况,我已经学会了如何使用仪器和NSZombie,但是我不能仅在模拟器上使用iPhone上的NSZombieEnabled运行仪器.我必须在iPhone中调试此问题,因为我正在使用UIImagePicker拍照,并且在拍照后不久便发生了错误.我也在使用ARC,所以我根本无法设置发布或保留信息,ARC禁止这样做,因此我怀疑它是双重发布还是类似的东西.这个问题有2种可能的答案.

I have been building an app for a client and everything was going smoothly until I started getting this error. This is a unique situation, I've learned how to use instruments and NSZombie however I can't run instruments with NSZombieEnabled on the iPhone only on the simulator. I have to debug this problem in the iPhone because I'm using UIImagePicker to take a picture and the error happens shortly after I take the picture. I'm also using ARC so I can't set release or retain info at all, ARC forbids it, so I doubt its a double release or anything like that. There are 2 possible answers to this question.

1:有人知道我是否可以使用照相亭将图像传递到UIImagePicker中吗?如果我可以通过摄影机屏幕,就可以使用仪器和NSZombie.

1: Does anyone know if I can pass an image into UIImagePicker using photo booth? I could use instruments and NSZombie if I could get passes the camera screen.

2:有没有一种方法可以检测出哪一行会导致错误,而无需使用iPhone重构或注释掉代码?有人知道在iPhone上追踪bad_acces的有效方法吗?

2: Is there a way to detect what line would be causing the error without refactoring or commenting out code using the iPhone? Does anybody know an efficient way to track down bad_acces on the iPhone?

请记住,我正在使用ARC,无法在模拟器上调试它.如果我取出UIImagePicker控制脚本,则不会发生该错误,因此我将其范围缩小到了CameraViewController类中的某个位置.恐怕由于已有合同,我无法发布任何代码,您必须是一名雇员才能查看源代码.

Keep in mind I am using ARC and cannot debug this on the simulator. If I take out the UIImagePicker control script the bug does not happen so I've narrowed it down to something in my CameraViewController class. I'm afraid I can't post any code due to a preexisting contract, you would have to be an employee to view source code.

很抱歉,信息有限,但实际上我正在寻找有关调试的答案,而不是直接解决我的确切代码问题.

Sorry about the limited information but really I'm looking for an answer about debugging not a direct solution to my exact code problem.

要发布回溯(我认为)

(gdb) bt
#0  0x339737e4 in objc_msgSend ()
#1  0x31b30140 in -[UIApplication sendAction:to:from:forEvent:] ()
#2  0x31b300e0 in -[UIApplication sendAction:toTarget:fromSender:forEvent:] ()
#3  0x31b300b2 in -[UIControl sendAction:to:forEvent:] ()
#4  0x31b2fe04 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#5  0x31b30452 in -[UIControl touchesEnded:withEvent:] ()
#6  0x31b2eddc in -[UIWindow _sendTouchesForEvent:] ()
#7  0x31b2e756 in -[UIWindow sendEvent:] ()
#8  0x31b299fe in -[UIApplication sendEvent:] ()
#9  0x31b29336 in _UIApplicationHandleEvent ()
#10 0x3026c04a in PurpleEventCallback ()
#11 0x3443fce2 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#12 0x3443fca6 in __CFRunLoopDoSource1 ()
#13 0x3443256c in __CFRunLoopRun ()
#14 0x34432276 in CFRunLoopRunSpecific ()
#15 0x3443217e in CFRunLoopRunInMode ()
#16 0x3026b5f2 in GSEventRunModal ()
#17 0x3026b69e in GSEventRun ()
#18 0x31ad0122 in -[UIApplication _run] ()
#19 0x31ace12e in UIApplicationMain ()
#20 0x000034ce in main (argc=1, argv=0x2ffff75c) at /Users/Andrew/Documents/Developing/Xcode Projects/ProjectSVN/Project/trunk/ProjectInterface/ProjectInterface/main.m:16

推荐答案

没有代码示例很难说,但是ARC并不能完全覆盖您的所有基础.例如,当对象(带有委托的类)不存在但尝试执行回调委托方法时,可能会出现这些EXC_BAD_ACCESS错误.

Without code samples it is hard to say, however ARC doesn't totally cover all of your bases. For example, it is possible to get these EXC_BAD_ACCESS errors when objects (classes with delegates) do not exist, yet try to execute callback delegate methods.

更具体地说,假设我在viewDidLoad:中创建了一个类-称它为ClassA.在我的假设情况下,我将视图控制器设置为ClassA的委托.但是,我尚未声明ClassA的属性,因此在viewDidLoad:的范围之外没有对它的引用.

To be more specific, let's say I have created a class in viewDidLoad: - let's call it ClassA. In my hypothetical situation, I set my view controller to ClassA's delegate. However, I have not declared a property for ClassA, so there is no reference to it beyond the scope of viewDidLoad:.

现在让我们假设ClassA声明一个由我的视图控制器实现的委托方法.该委托在此委托方法中将自身的引用传递回视图控制器.因为这可能会或可能不会超出范围,BOOM会出现错误的访问错误.检查诸如此类的事情,其中​​对象不再存在,并被传递给其他方法-这是ARC可能会使您失败的一种方式;)

Now let's assume ClassA declare a delegate method that is implemented by my view controller. This delegate passes a reference of itself back to the view controller in this delegate method. Because it may or may not be out of scope by this point, BOOM, bad access error. Check for things such as this, where objects do not exist anymore and are being passed to other methods - it is one such way ARC can fail you ;)

这篇关于使用ARC的EXC_BAD_ACCESS,无法在模拟器上跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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