EXC_BAD_ACCESS 消息发送到解除分配的实例,但我使用的是 ARC? [英] EXC_BAD_ACCESS message sent to deallocated instance, but I'm using ARC?

查看:18
本文介绍了EXC_BAD_ACCESS 消息发送到解除分配的实例,但我使用的是 ARC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从 SOAP Web 服务获取信息的应用程序,我想在 UITableView 中显示结果.

我有这个应用程序的以前版本,我正在创建一个新版本来基本上清理内容并摆脱一堆已弃用且不再使用的遗留代码.

在以前的版本中,这运行良好.在新版本中,没有那么多.

基本上,当前场景返回 3 个字符串,我试图将其用作 UITableView 中数据的基础.

我正在努力解决这个问题,因为追踪 EXC_BAD_ACCESS 错误太难了!

(顺便说一句,如果有人有办法让调试体验更像 Visual Studio,我很想听听!不知道哪一行导致了错误,而且无法在崩溃时查看我的局部变量,看看是什么.我已经添加了异常断点,但这似乎没什么用.)

无论如何,导致错误出现的行是:

return [[self Libraries] count];

它发生在tableView:numberOfRowsInSection:.

我收到的错误消息似乎引用了一个应该存储在 NSMutableArray [self Libraries] 中的字符串.

这是怎么回事?
我正在使用 ARC,所以我的所有内存管理都不应该被正确处理吗?
我的代码中没有任何手动发布声明!

请帮我解决这个问题!

解决方案

Set NSZombieEnabledMallocStackLogging保护 malloc 在调试器中.然后,当您的应用程序崩溃时,在 gdb 控制台中输入:

(gdb) info malloc-history 0x543216

0x543216 替换为导致崩溃的对象的地址,您将获得更有用的堆栈跟踪,它应该可以帮助您查明代码中导致问题的确切行.

查看这篇文章了解更多详细说明.>

I've got an app that gets information from a SOAP web service and I want to display the results in a UITableView.

I had a previous version of this app and I'm creating a new version to basically clean things up and get rid of a bunch of legacy code that's deprecated and no longer used.

In the previous version, this worked well. In the new version, not so much.

Basically, the current scenario is returning 3 strings that I'm trying to use as the basis for the data in my UITableView.

I'm struggling with this issue because it's so stinkin' hard to track down EXC_BAD_ACCESS errors!

(Parenthetically, if someone has a way to make the debug experience more like Visual Studio, I'd love to hear it! It's so frustrating to not have any idea which line caused the error, and also to not be able to look through my local variables at the time of the crash to see what's what. I've already added in the exception breakpoint, but that doesn't seem to do much.)

Anyway, the line that's causing the error APPEARS to be:

return [[self Libraries] count];

It occurs in tableView:numberOfRowsInSection:.

The error message I get APPEARS to reference a string that should be stored in the NSMutableArray [self Libraries].

What's going on here?
I'm using ARC, so shouldn't all of my memory management be correctly handled?
I don't have any manual release statements in my code ANYWHERE!

Please help me fix this!

解决方案

Set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:

(gdb) info malloc-history 0x543216

Replace 0x543216 with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.

See this article for more detailed instructions.

这篇关于EXC_BAD_ACCESS 消息发送到解除分配的实例,但我使用的是 ARC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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