Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 at 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!)

enter image description here

like image 305
nacho4d Avatar asked Jan 19 '23 22:01

nacho4d


1 Answers

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.

like image 190
Joshua Nozzi Avatar answered Jan 30 '23 22:01

Joshua Nozzi