14

I'm trying to get better at using Xcode. I have the AllExceptions break point turned on. When my app crashes, I see this:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0xbb8052 0x209cd0a 0xba4db8 0x2255f2 0xc2439 0x12a5e0f 0x12a6589 0x146bfb1 0x147617c 0x12938e1 0x1290602 0x129b211 0x129b23f 0xc16a6 0x138a4c 0x138852 0x14d0e39 0x14d0143 0x14d13cf 0x14d3a31 0x14d398c 0x14cc3e7 0x1234812 0x1234ba2 0x121b384 0x120eaa9 0x28d3fa9 0xb8c1c5 0xaf1022 0xaef90a 0xaeedb4 0xaeeccb 0x28d2879 0x28d293e 0x120ca9b 0x265c 0x25c5)
terminate called throwing an exception(lldb) 

On the LHS, when I look at the different threads, I don't see anything that really makes sense. I see some CFRunLoop stuff, but I don't see any "normal" method names like UITableView delegate/datasource methods or my own methods. I was wondering if there was a more informative stack trace available instead of the hex stuff when my app crashes. I know I can set breakpoints at each place I'm accessing the array I think I have a problem with since I'm basically just trying to have an accordion-like tableview with our specific datasource, but I was wondering if there was a faster way by looking at something useful in Xcode. Thanks!

2
  • Search for any loops you make in your code and check if you call index our of bounds. you have an array have only one object and you call array[1] Commented Feb 21, 2013 at 22:16
  • As my experience, i think there is any tool in xcode can help you in this. If you run on device, you can see the log from Organizer and there you may fine more useful Info Commented Feb 21, 2013 at 22:19

2 Answers 2

45

In Xcode,

  1. go to Breakpoint navigator on the left pane.
  2. Click '+' at the bottom.
  3. Choose 'Add exception Breakpoint...'
  4. Let the default selections there and click 'Done'.

Rerun the app and see if execution stops at the line which causing this exception.

Sign up to request clarification or add additional context in comments.

1 Comment

Say you have 1000 handled exceptions and you want to find the one uncaught exception, then this isn't helping very much...
3

The easiest way to handle the exceptions in XCode during development is to add the exception break points.

You can do that as following.

  1. From left menu select Exceptions navigator

enter image description here

  1. Add the exception break point from bottom left button.

enter image description here

  1. Add break point for all the exceptions

enter image description here

  1. Run the app.

In most of the cases XCode will stop the execution on exception and point at the line that caused the exception.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.