The error “This class is not key value coding-compliant for the key” is a common problem for iOS developers which causes an app to crash right at launch. Read on to find out the solution to the issue.
This error is often the result of a missing connection between an object in the storyboard and an IBOutlet in the code file. One common scenario which causes this is when you accidentally create an unnecessary IBOutlet in code, and you just delete the outlet declaration without removing the connection on the object in the storyboard. For small projects, finding and deleting the problematic connection is easy. However, when you have multiple objects in a storyboard, finding the right one could take a lot of time.
When your app crashes at launch, you will see the following message in the debug area. If the stack trace is long, you will have to scroll all the way to the top of the window to see it.
Here is how you can quickly find the problematic object inside the storyboard without manually going through all of the elements:
1. Copy the text right after the generic error message. The text is actually the IBOutlet name that you deleted from the code file and is unique to your project.
2. Open the Navigator panel, and then switch to the Search tab. In this tab, paste the text in the search field, and hit Enter.
3. When the results show up, find the one in the storyboard file starting with the Outlet text. Now, you have successfully identified the root of the problem.
4. To fix the issue, simply tap on the result to open the Connections section in the Utilities panel. Find the outlet with the exclamation mark at the end, and click the X button to remove the connection.
5. Run the project again to verify that everything works as expected.