随机EXC_BAD_ACCESS在一个不可能发生的地方 [英] Random EXC_BAD_ACCESS in a place that it cannot happen
问题描述
我在某个地方随机收到EXC_BAD_ACCESS我确认不应该发生异常。
它发生的行是
I'm receiving EXC_BAD_ACCESS at random times in a place that I confirmed the exception should not happen.
The line its happening on is
`[[LevelEditorScene sharedLevelEditor] setObject:object forKey:key]`
LevelEditorScene
是一个类, setObject:forKey:
是我实现的方法(不是来自<$的方法) c $ c> NSObject )
在GDB中:
LevelEditorScene
is a class, setObject:forKey:
is a method I implemented (not the one from NSObject
)
In GDB:
(gdb) print-object [LevelEditorScene sharedLevelEditor]
<LevelEditorScene = 06C3FF40 | Tag = -1>
意味着 LevelEditorScene sharedLevelEditor
没问题。
(gdb) print (bool)[[LevelEditorScene sharedLevelEditor]
respondsToSelector:@selector(setObject:forKey:)]
$9 = true
表示它响应选择器
(gdb) print-object object
15
(gdb) print-object key
Maze Width
表示参数正常(无论如何都应该无关紧要)。
还有什么可以导致例外?
Means the arguments are ok (it shouldn't matter anyway).
What else can be causing the exception?
推荐答案
您的应用程序崩溃的代码行可能不是问题的原因。很可能你的方法调用很好。否则,您将收到发送到无法识别的选择器的消息错误。
The line of code that your app crashes on might not be the cause of the problem. Most likely your method call is fine. Otherwise you'd receive a "message sent to unrecognised selector" error.
最好的步骤是运行Analyzer。使用仪器中的泄漏使该配置文件失败。
The best steps are to run the Analyzer. Failing that Profile using Leaks in Instruments.
有关EXC_BAD_ACCESS的精彩描述,原因以及调试方法可在此处找到:
A brilliant description on EXC_BAD_ACCESS, what causes it, and how to debug it can be found here:
这篇关于随机EXC_BAD_ACCESS在一个不可能发生的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!