I have created a swift file MainViewController
that declares/defines a class MainViewController
. I've set my storyboard's only scene's custom class as this class. I have the following code:
import Foundation
class MainViewController : UIViewController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
fatalError("init(coder:) has not been implemented")
}
func setup() {
self.view.backgroundColor = UIColor.blueColor()
}
}
When I run the project I get the following crash log:
fatal error: init(coder:) has not been implemented: file /Users/alexanderbollbach/Desktop/DraWave/content/MainViewController.swift, line 17
It seems that this is an issue people have experienced before and that swift has introduced some complexities regarding view controller initialization. I am currently learning swift but cannot resolve what the issue is. It may be worth noting that this is a mixed-language project that contains objective-c classes.