I've tried all answers from previous questions but am still getting errors when I try to subclass UIView and add my own initializer. This is the code:
class ProgressAlertView: UIView {
var title: String
var steps: Int
var messageLabels: [String]
var errorLabel: String
var successLabel: String
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
alertLayout()
}
public override init(frame: CGRect) {
super.init(frame: frame)
alertLayout()
}
convenience init(title: String, steps: Int, messageLabels: [String], errorLabel: String, successLabel: String) {
self.init(frame: frame)
self.title = title
self.steps = steps
self.messageLabels = messageLabels
self.errorLabel = errorLabel
self.successLabel = successLabel
}
}
This throws this error in both the required and override methods:
Property 'self.title' not initialized at super.init call
In an answer to a previous question someone explained that one needs to set the parameters first before calling the super.init(). When I try that, I get the following error messages (on top of the ones from above): 'self' used in property access 'title' before 'self.init' call
What's the correct way to do this?