Reputation: 173
I was wondering if anyone else had run into this problem;
I need to add the line @objc(NewClassName) to my View Controller so that it can be seen by its Objective-C counterparts with an Objective-C prefixed class name.
import UIKit
@objc(NewClassName)
class ClassName: UIViewController {
Adding the @objc line gives the error:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x17f62f70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mainView.'
Note: mainView is a View I have added myself. This error does not crop up without the @objc
Removing the @objc line makes it all work as intended.
This is how it is set up in the Storyboard:
Upvotes: 1
Views: 111
Reputation: 32789
You need to update the storyboard class name to NewClassName
. The runtime doesn't find ClassName
and instantiates a generic UIViewController
, causing the exception.
Upvotes: 1