This is a Solution for an error I was getting on the FoodTracker app tutorial provided by Apple.
The Exception:
2016-07-30 11:00:08.896 FoodTracker[898:115935] Unknown class MealTableViewCell in Interface Builder file. Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key nameLabel.
After much research I have noticed that this is a common error thrown out by Xcode( my version: 7.3.1.) that could be caused by many different issues. This error occurred for me when I was trying to create a custom Table View with a Custom cell.
What happened was when I added a new TableView in my StoryBoard and set the prototype cell class to be my custom cell type, the module identity did not default properly.
The key part of the exception is “Unknown class MealTableViewCell in Interface Builder file.” Meaning that the class “MealTableViewCell” is not setup properly in the Storyboard.
The identity Inspector for my custom cell looked like this when the error was being thrown:
The problem with the module not being set is that XCode will not be able to recognize my custom cell type so it throws a NSUnknownKeyException.
It should look like this:
You see that the Module Box is defaulted to “Current – **AppName**”. The module identity helps Xcode recognize the custom cell class.
The way I was able to get the correct default was to tap enter in the Module TextBox, then click on the dropdown icon to see my app name. I then clicked on my app name to set the module correctly.
If it still doesn’t show, try re-entering the class name or re-creating the view.
I am not sure how my custom cell class module did not default properly but I believe it is a bug with Xcode. If you are getting an error similar to this one I would suggest making sure that all of your views (particularly custom views) have the correct identities in the Storyboard Identity Inspector.