Search code examples
ioserror-handlingcrashterminate

Terminating the app due to uncaught exception 'NSUnknownKeyException' - IOS


I keep getting this type of error and the app gets crashed. Can anyone help me understand what this is exactly and how to understand what's the exact error. Help would be really appreciated.

Advancial[39482:1348062] Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<QuickLookViewController 0x7f8eebdd37c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key main.'

Is there any way like it indicates the line number where it is throwing the error, like in java?, i want to get my head into how to solve this issue if faced again in future. Thanks


Solution

  • You have the call stack in Xcode. You can also set a breakpoint that will break on all exceptions, all C++ exceptions, or all Objective-C exceptions so your app stops at the point where the exception is thrown.

    Note that unlike Java, exceptions in Objective-C usually indicate programming errors. So you would never try to catch the exception, but find out what bug caused the exception, and fix your code.