开发者

Random EXC_BAD_ACCESS in a place that it cannot happen

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 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>

Means LevelEditorScene sharedLevelEditor 开发者_如何学Gois ok.

(gdb) print (bool)[[LevelEditorScene sharedLevelEditor]
                    respondsToSelector:@selector(setObject:forKey:)]
$9 = true

Means it responds to the selector

(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.

The best steps are to run the Analyzer. Failing that Profile using Leaks in Instruments.

A brilliant description on EXC_BAD_ACCESS, what causes it, and how to debug it can be found here:

Lou Franco's Understanding EXC_BAD_ACCESS

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜