When I bring up console after my iPhone app crashes, it often says "unrecognized selector sent to instance 0x blah blah blah." How can I find out what variable this is? Is there a way in the debugger? Is it even possible? Thanks.
Asked
Active
Viewed 7,558 times
2 Answers
21
In gdb you could type
po 0x12345678
to print the -description
of the object at that address. But this info is seldom useful. You should instead check the backtrace of the exception first, which can locate the line of code that causes the problem.

kennytm
- 510,854
- 105
- 1,084
- 1,005
-
Yeah I can't figure that out either. Is the line number of the code that caused the exception the number after the + on the call stack? – marty Aug 04 '10 at 08:33
-
@marty: Are you compiling for debugging? There's no need to check these complicated information. Just use the built-in debugger. See [ *iOS Development Guide: Debugging Applications* ](http://developer.apple.com/iphone/library/documentation/xcode/conceptual/iphone_development/130-Debugging_Applications/debugging_applications.html) and [ *Xcode Debugging Guide* ](http://developer.apple.com/iphone/library/documentation/DeveloperTools/Conceptual/XcodeDebugging/000-Introduction/Introduction.html#//apple_ref/doc/uid/TP40007057). – kennytm Aug 04 '10 at 08:47
-
This is the most useful answer I found here :) – shannoga Jul 05 '12 at 13:46
-
This helped me find a bug I've spent hours looking for, thanks! – inorganik Jul 28 '15 at 14:57
14
It's very helpful to create an Exception breakpoint, and with Xcode 7.3, it's never been easier. This will help you find the line of code causing an exception.
- add breakpoint on the line where the app crashes
- click the breakpoint in the Project Navigator menu
- find the breakpoint you just created and select it
- click the "+" at the bottom left
- Select "Add Exception Breakpoint"
Run your code...whenever you get a "unrecognized selector sent to instance 0x blah blah blah," the debugger will stop on the line that's causing the problem.

whyoz
- 5,168
- 47
- 53