Home:ALL Converter>Initialize a subclass of UIViewController with Swift?

Initialize a subclass of UIViewController with Swift?

Ask Time:2014-06-03T16:50:49         Author:user3587825

Json Formatter

I'm trying to understand how initialization works in Swift with a subclass of a UIViewController. I thought the basic format was this, but it is throwing errors...

init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!)   {
    //other code
    super.init(nibName: String?, bundle: NSBundle?)
}

Author:user3587825,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24010861/initialize-a-subclass-of-uiviewcontroller-with-swift
Leandros :

You're passing the types, not the variables. You have to pass the variables instead.\n\ninit(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {\n // Initialize variables.\n\n super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)\n}\n",
2014-06-03T09:13:28
JulioBarros :

Variables should now be initialized before the call to super.init\n\ninit(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {\n\n // Initialize variables.\n\n super.init() // as required\n}\n",
2014-06-09T19:27:19
yy