Swift: 'super.init' isn't called on all paths before returning from initializer?

Since you inherit from UIViewController, you should call super.init right after you set the variables in your init function

When you inherit a class and implement a new init function or override its own init function you should (almost) always call super.init. Let's take your example, you inherited from UIViewController. UIViewController has a few init functions that you can use to initialize a view controller. if you don't call super.init, all the code inside those functions will not get called and possibly the view controller won't get initialized.

Anyway, this piece of code should work for you:

class ViewController: UIViewController {

    var button: UIButton?

    init(button: UIButton) {
        self.button = button
        super.init(nibName: nil, bundle: nil)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}