开发者

Debugging -[NSCFDictionary setObject:forKey:]: attempt to insert nil value

I have done some changes to my project and now I am getting above message when running the app and don't how how to debug it. I have read here that I have to put a break point in -[NSCFDictionary setObject:forKey:] and set a condition as well.

But, how do I set the condition they mentioned? (Stop only when value is nil) I am on Xcode4 and only get this window when trying to set a breakpoint.

Currently it stops a开发者_JS百科t every -[NSCFDictionary setObject:forKey:] which is not very helpful since it will stop even in correct calls and Apple's internal calls as well (too many!)

Debugging -[NSCFDictionary setObject:forKey:]: attempt to insert nil value


Remove that breakpoint and add an Exception breakpoint. This will stop on any exception (like attempting to insert nil into a dictionary). It's good practice to leave this breakpoint on for all debugging sessions, that way even intermittent exceptions (those hard-to-find problems) will be caught in the debugger the moment they happen.

To add an Exception breakpoint, click the Add (+) button at the bottom of the breakpoints list and click Add Exception Breakpoint. Leave it configured as-is.


if you have reduced it to a call site, you can simply write:

assert(object);
[dictionary setObject:object forKey:key];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜