How to debug ‘unrecognized selector send to instance’
2 min readFeb 23, 2020
In most of the cases Xcode do not take us to the exact line where this issue happen. When app crash you won’t see the line of code that caused this rather you will be taken to App delegate class, with error output something following:
[UITableViewCellContentView image]: unrecognized selector sent to instanceor [__NSDictionaryI objectAtIndex:] unrecognized selector sent to instanceor*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TestApp.MyViewController viewDidLoad:]: unrecognized selector sent to instance 0xDABCDD'
How to find line of code causing this:
Go to breakpoint navigator. Click ‘+’ option. click ‘Exception Breakpoint’. An new widget like following will apear.
Add following condition block:
-[NSObject(NSObject) doesNotRecognizeSelector:]
*you can also put breakpoint for all exception.
Now run your code again. this time, breakpoint will trigger when this exception occurs.