Sorry if this was asked before, I searched a lot many times, and many answers came from Swift's earlier blinds, when things were different. I can not find the final answer.
I want to subclass UIViewController and have a custom initializer so that I can easily configure it in code. I have problems with this in Swift.
I need an init() function that I can use to pass a specific NSURL , which I will use with the view controller. In my opinion, it looks like init(withImageURL: NSURL) . If I add this function, it will ask me to add the init(coder: NSCoder) function init(coder: NSCoder) .
I believe this is due to the fact that it was marked in the superclass with the keyword required ? So should I do this in a subclass? I add it:
required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
Now what? My special initializer is considered a convenience one? Appointed? Can I call a super initializer? An initializer from the same class?
How to add my special initializer to a subclass of UIViewController ?
initialization uiviewcontroller swift
Doug Smith Nov 14 '14 at 4:40 2014-11-14 04:40
source share