When you see the TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION message there is more info in the Xcode Debugger Console. Open up the console window and look for the kind of exception. As mentioned upthread there are different kinds of exceptions. Looking at the kind of exception will help you to figure out the problem. You can also see the NSLog output in Console.app.
Also, by the time the app is terminated due to the uncaught exception there is no useful backtrace. If you set a breakpoint on objc_exception_throw the debugger will break before the exception is thrown and you'll have a useful backtrace. I do this with a .gdbinit file. Create a file named .gdbinit and place it in your home directory. This is the contents of mine:
fb -[NSException raise]
fb -[_NSZombie release]
fb szone_error
fb objc_exception_throw
It's also possible to set these kinds of breakpoints in the Xcode breakpoints window or in the debugger console.
At any rate, the usual reason for an exception with replaceObjectAtIndex is out of range. Another reason is that your instance variable has already been released due to faulty memory management so you message a stale pointer.
|