I am not using a UIViewController
from a storyboard and I want to have a custom init
function where I pass in an NSManagedObjectID
of some object. I just want to call super.init()
like I have in Objective-C. Like this:
init(objectId: NSManagedObjectID) {
super.init()
}
But I get the following compiler error:
Must call designated initializer of the superclass UIViewController
Can I simply not do this anymore?
The designated initialiser for UIViewController
is initWithNibName:bundle:
. You should be calling that instead.
If you don't have a nib, pass in nil
for the nibName (bundle is optional too). Then you could construct a custom view in loadView
or by adding subviews to self.view
in viewDidLoad
, same as you used to.