SunburstEnzo
SunburstEnzo

Reputation: 173

Adding @objc(NewClassName) breaks Storyboard references in Swift

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 {

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:

Storyboard setup

Upvotes: 1

Views: 111

Answers (1)

Cristik
Cristik

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

Related Questions