如何仅在设备上调试 EXC_BAD_ACCESS

发布于 2024-11-24 12:38:31 字数 530 浏览 0 评论 0原文

我有一些代码返回一个包含 2 个对象的结构(声明为 id)。 当尝试使用其中一个对象时,我收到 EXC_BAD_ACCESS 并且应用程序崩溃。这仅发生在设备(ipad)上,而不发生在模拟器中。

我已将 NSZombieEnabled 设置为 YES,但是没有信息写入控制台。 我不知道我在 Xcode 4 中使用工作区是否存在问题,一个项目用于我的应用程序,另一个项目构建了一个在我的应用程序中使用的库。 EXC_BAD_ACCESS发生在第二个项目中,所以我不知道NSZombieEnabled是否适用于第二个项目?

我该如何解决这个问题?特别是因为我它只发生在设备上(甚至按计划在模拟器上进行),并且它在第二个项目中?

编辑: 这是 EXC_BAD_ACCESS 的方法发生在 sortRange.lower 的第 62 行 –

I have some code that returns a struct containing 2 objects (declared as id).
When trying to use one of the objects I get an EXC_BAD_ACCESS and the app crashes. This only happens on the device (ipad) not in the simulator.

I have set NSZombieEnabled to YES, however no information is written to the console.
I don't know if it's a problem that I'm using a workspace in Xcode 4, one project for my app, and another that builds a library which is used in my app. The EXC_BAD_ACCESS is occurring in the second project, so I don't know if NSZombieEnabled will apply to the second project?

How do I solve this? Especially as I it only happens on the device (even goes as planned on the simulator), and it is in the second project?

EDIT: This is the method where the EXC_BAD_ACCESS occurs, on line 62, on sortRange.lower –

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋风の叶未落 2024-12-01 12:38:31

NSZombieEnabled 仅适用于模拟器,不适用于设备,因此它可能隐藏了问题。运行产品>分析(⇧⌘B)寻找线索。不看代码就很难说更多。正如 Mihai 所说,您的对象可能被过度释放,这是 EXC_BAD_ACCESS 的最常见原因。

NSZombieEnabled only works on the simulator, not on the device, so it's probably hiding the problem. Run Product > Analyze (⇧⌘B) for clues. It's harder to say more without looking at the code. As Mihai says, your objects are probably over released, which is the most common cause of EXC_BAD_ACCESS.

蓦然回首 2024-12-01 12:38:31

似乎您的一个对象在您尝试访问它之前已自动释放。由于 iPad 的内存比您运行它的计算机少,因此它的释放速度更快,因此它不可用。尝试在出现错误的行之前对两个对象进行 NSLog,看看其中一个是问题所在,然后追溯到它的起源并以某种方式保留它。使用完后不要忘记释放它。一些示例代码会很有用。

It seems that one of your objects is autoreleased before you are trying to access it. As the iPad has less memory than the computer you are running it on it get's released faster so that's why it's not available. Try NSLog both objects just before the line you are getting the error and see wich one of them is the problem and than trace back to it's origin and retain it somehow. Also don't forget to release it after you are done using it. Some example code would be useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文