应用程序崩溃且没有任何日志消息
在我的应用程序中,我有一个 UIViewController,它由另一个 ViewController 的导航控制器推送。它包含一些视图、按钮、滚动视图和加速度计支持。当我点击 navigationController 的“后退”按钮时,应用程序崩溃,没有任何日志消息,除了以下一条: “警告:无法读取 /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib 的符号(未找到文件)。 (gdb)” 调试器将我链接到 main.m 中的这一行:
int retVal = UIApplicationMain(argc, argv, nil, nil);
带有“EXEC_BAD_ACCESS” 这是什么意思?
编辑: 你们都是对的。 问题出在加速度计上。我设置了 delegate ([UIAccelerometer sharedAccelerometer].delegate = self;) 并且没有删除它。这就是为什么我的代码中没有可供调试器链接的行。我刚刚添加了这个:
- (void)viewWillDisappear:(BOOL)animated {
[UIAccelerometer sharedAccelerometer].delegate = nil;
}
问题就消失了。因此,如果您正在使用任何设备功能,请小心代表。
In my App I have an UIViewController, that pushed by another ViewController's navigation controller. It contains some views, buttons, scrollViews and accelerometer support. When I tapping "back" button of navigationController, app crashes without any log message, except this one:
"warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
(gdb)"
debugger links me to this line in main.m:
int retVal = UIApplicationMain(argc, argv, nil, nil);
with "EXEC_BAD_ACCESS"
what does this mean?
EDIT:
all of you are right.
problem was in accelerometer. I setted delegate ([UIAccelerometer sharedAccelerometer].delegate = self;) and didn't remove it. that's why there was no line in my code for debugger to link to. I just added this:
- (void)viewWillDisappear:(BOOL)animated {
[UIAccelerometer sharedAccelerometer].delegate = nil;
}
and problem gone. So, If you are using any device functions, be careful with delegates.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否将僵尸设置为启用?这将使您能够跟踪是否访问已释放的对象,并告诉您它是哪个对象。
如果您使用的是 XCode 4,您可以在 Project -> 中启用僵尸。编辑方案->通过选中“启用僵尸”复选框进行诊断。
另外,请确保您已设置“异常中断” - 在 XCode 4 中,转到 断点视图,按左下角的加号,然后选择“添加异常断点.. .” 对于所有例外情况。然后 XCode 将在异常发生的地方中断,并且您将看到的不仅仅是 UIApplicationMain 作为位置。
Did you set Zombies to enabled? That will enable you to track if you access an already released object, and that tells you which object it is.
If you are using XCode 4, you can enable zombies in Project -> Edit Scheme -> Diagnostics by checking the "Enable Zombies" checkbox.
Also make sure you have "Break on Exception" set on - in XCode 4 go to the Breakpoint View, press the Plus sign in the lower left corner, and choose "Add Exception Breakpoint ..." for all exceptions. Then XCode will break at the point where the exception occurs, and you will see more than just UIApplicationMain as the location.
这意味着您尝试读取/写入您无权访问的内存块。也许您正在尝试使用尚未分配/初始化的对象。检查代码、调试代码并检查变量以找到解决方案。
This means you have tried to read/write a block of memory you have no permission to. Maybe you're trying to use an object you haven't allocated/initialized. Check your code, debug it and inspect variables to find a solution.
我猜你有一个内存警告,并且你的应用程序释放了一些当你返回时不再存在的数据。
在
didReceiveMemoryWarning
、dealloc
、viewDidUnload
和viewDidLoad
中放置一些断点,以查看之前的控制器中发生的情况。I guess you had a memory warning and you app deallocated some datas tha are not there anymore when you go back.
Put some breakpoint into
didReceiveMemoryWarning
,dealloc
,viewDidUnload
andviewDidLoad
to see what happens in your previous controller.EXC_ BAD_ ACCESS 是一个例外(EXCeption_ BAD_ ACCESS)。
如果您在 objc_exception_throw 上设置断点(调试选项卡左下角的 + 号),您将得到这些断点。
您可能需要查看 NSZombieEnabled (http://www.cocoadev.com/index.pl?NSZombieEnabled),因为您可能正在尝试访问已释放的对象。
EXC_ BAD_ ACCESS is an exception (EXCeption_ BAD_ ACCESS).
If you set a breakpoint on
objc_exception_throw
(sign + on the lower left corner of debug tab), you'll get those.You might want to look at
NSZombieEnabled
(http://www.cocoadev.com/index.pl?NSZombieEnabled), as you're probably trying to access a dealloc'd object.