0

All I have is a simple table view that downloads content from twitter using AFNetworking and then displays it in cells. I have paging enabled in my tableView, and sometimes when I scroll between my data on my iPad, my app just freezes and my Xcode screen changes to this:

enter image description here

I am new to Objective-C, but in Java when things like this happened, it wrote out a list of all the methods and line numbers in my code leading up to the crash. Is there any way to get it to do something like that? I don't understand anything about this, and the console is just blank.

Cezar
  • 55,636
  • 19
  • 86
  • 87
David Zorychta
  • 13,039
  • 6
  • 45
  • 81
  • Are you sure it's crashing? It looks like you have an exception breakpoint turned on. Try Product -> Debug -> Deactivate Breakpoints and see if it still happens. – Aaron Brager May 05 '13 at 20:02
  • I don't have any breakpoints but for some reason this just keeps happening randomly when I'm scrolling through my table view. – David Zorychta May 05 '13 at 20:04
  • You do have breakpoints; it's breaking on one. See where it says "breakpoint" on the right? If you deleted all your breakpoints and it's still happening try restarting Xcode. – Aaron Brager May 05 '13 at 20:06
  • It's hitting a "virtual" breakpoint due to getting an exception. The exception occurred in the highlighted function, which is some sort of dictionary init routine. If you're lucky the console has a printout telling you why precisely the exception was thrown, but I'm guessing you mucked up the table cell protocol somehow. You may be able to get more info about the specific cause (printed in the console) by editing your `main` routine per [this answer](http://stackoverflow.com/a/12268397/581994). – Hot Licks May 05 '13 at 20:13
  • Also, the library's routine may be able to handle the exception itself and your code might work fine without any changes needed. MPMoviePlayer, for example, sometimes throws exceptions and then handles them itself. (Side note: you can also delete all breakpoints in the lldb console by typing `br del`.) – Aaron Brager May 05 '13 at 20:31
  • Sometimes the console is completely blank, sometimes it says "2013-05-05 17:05:50.318 myapp[54018:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'" however, I don't know where this is within my project. – David Zorychta May 05 '13 at 20:31
  • This si happening on a call to init the dictionaty with the objects and keys. You are aytempting to insert a nill object into a dictionary (you cant insert nill objects in a dictionary in ob-c). Find the line that does this. Try setting a breakpoint that gets thrown on exceptions http://blog.manbolo.com/2012/01/23/xcode-tips-1-break-on-exceptions – William Falcon May 05 '13 at 21:02
  • Given the stack at the time that this happens, the error is probably occurring in some sort of "dispatched" code rather than your mainline code. This can be hard (*very* hard) to sort out, but it's likely something having to do with initializing a table cell or some such. My first suspicion would be that you've mucked up cellForRowAtIndexPath somehow, possibly by not following the protocol for cell reuse. – Hot Licks May 05 '13 at 21:18
  • I just don't know how to know where "initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]" is happening. – David Zorychta May 05 '13 at 23:56

2 Answers2

0

Check this question out. It will show you how to determine what is causing the exception.

As with Java, you can also add a try block and their corresponding catch and finally blocks to handle the exception. See this question.

Community
  • 1
  • 1
Jorge
  • 2,530
  • 1
  • 19
  • 28
  • I don't know where to place the try catch, I don't know what part of my program is crashing my app. – David Zorychta May 05 '13 at 23:55
  • I understand. Please first find out what the exception is about. It sounds to me like you are trying to create a dictionary from a nil array. It could be the case that your AFNetworking callback is returning nil. Please check what it is and we can continue from there. – Jorge May 06 '13 at 00:03
0

Its because you are using a dictionary in which the object and key at some point of cell is creating problem for you. Check your NSDictionary data.