开发者

How can this if-sentence trigger?

The variable fullscreenController is nil, but also not nil?

EDIT: Both the debugger and the console print says the variable is nil, but the if sentence still triggered.

开发者_C百科

How can this if-sentence trigger?

How can this if-sentence trigger?


It couldn't be, in a single-threaded application; in a sloppily-written multithreaded app, though, I suppose it could be nil by the time you get to that part of the code. But I suspect this is either a cut-and-paste error, or just an example of not thinking.


Although very unlikely, another possible cause is zeroing weak references. If your local thread holds only weak references to fullscreenController, and the last strong reference is released, all zeroing weak references become nil. There's a remote possibility this could happen between the if test and the branch body code.

As ZWRs are common in automatically reference counted code, this sort of issue will become more regular in iOS 5 and Lion, - at least until people work out exactly how to use ARC.


Try doing a clean everything and rebuild. It could be that the source code is out of step with the executable.

Also, make sure you are not trying to debug the release build. Sometimes, the optimisation of release builds confuse the source view in the debugger.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜