How to fix iOS Swift XCODE NSUnknownKeyException
The NSUnknownKeyException is most likely caused by a broken outlet in your view controller. You can identify the screen throwing this error using the log. The [project_name].[view_controller_name] gives the view controller and the outlet name is given which is ‘tipControl’ in the above example. To fix this error follow the following steps:
STEP 1: Go to the storyboard containing the broken outlet here it is main.storyboard
STEP 2: Open the “Connections Inspector” tab on the right
If you try running the app at this point you will get the following error. This is because we missed a crucial step in fixing the original error. You can see in the debug session that the value for “myTipControl” is nil.
STEP 3: Open the storyboard again and drag and connect the nil outlet to the right UI element in the storyboard as shown:
STEP 4: Run the app again and it works successfully.