0

I am trying to debug a crash on my app

all i get is

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

I know its a problem with a fetch from CoreData that is returning nil.

Now my objective is to see where the crash is it coming from exactly. I know there is a way to check with Instruments the exact line of code that causes my code to crash.

Could anyone point me in the right direction on which instrument would give me that information and some debugging tips when trying to find the line in Analyzer?

Jonathan Thurft
  • 4,087
  • 7
  • 47
  • 78
  • Not sure who downvoted iAmbitious, or why he deleted his correct answer. That's not something you do in Instruments or in the Analyzer, you use the Debugger for this kind of bugs. [Add an Exception Break Point](http://stackoverflow.com/a/14767076/457406) so the debugger will stop when this exception is thrown. Then navigate the call stack back to the offending line. – Matthias Bauch Sep 30 '13 at 19:09
  • Actually if you check the apple videos they have used `Analyzer` to detect exact lines of code execution in bugs. Apple recognizes that is possible, check advance debugging videos. Doing stop breaks takes time and can be quite tricky in my case as the error is a result of a conflict in the program and I can not replicate the problem in the simulator. – Jonathan Thurft Sep 30 '13 at 19:13

1 Answers1

0

As per your error log, in my understanding you trying to insert nil value in NSDictionary/NSMutableDictionary. You can not pass nil as value or key into dictionary otherwise your code will crash. My suggestion you debug you code using breakpoint, trace you execution stack i believe you will get your exact solution where your nil value inserting in dictionary.

If you want to find exact line of crash you can take help of debugger command. Enter bt (back trace command) in debugger window, it will give also same executed crash stack that give you instrument analyzer. Go through following links

https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_5_0.html

http://www.cimgf.com/2012/12/13/xcode-lldb-tutorial/

Tirth
  • 7,801
  • 9
  • 55
  • 88
  • I didn't downvote it. But if you check the WWDC Videos. In one of the latest videos its shown how they debug using `analyzer` to check exact lines and say that it can be use as such. I cant make it work as in the video, but that says is possible. also your suggestion is valid if i knew which dictionary is causing the problem, I've loads of dictionaries and the evident ones were fine. – Jonathan Thurft Sep 30 '13 at 19:39
  • @JonathanThurft, yes that true instrument analyzer also give you exact line of crash. See right side of widow, there is stack of execution. In that stack 1st one dark line is an crash line. If you click on that line you will got all code middle box of instrument. But in your case your error is mostly familiar and understandable you need not take help of analyzer. Please see now my updated answer – Tirth Oct 01 '13 at 07:06
  • How do you know the error is most familiar and understandable? My error doesn't break on a exact line of execution when crashing, not crashes referencing a class in the consolelog, and doesnt even crash telling me the right process on the thread processes on the left menu. . thats why I need `analyzer`. It crashes not referencing anything. thats why what I need is advance debugging and the question is related to **advance analyzer debugging**... – Jonathan Thurft Oct 01 '13 at 08:09