I'm trying to create a class which inherits from NSObject that can only be initialised given the required parameters. I can achieve this as follows:
class MyTestClass: NSObject {
var myTestValue: String
var myTestValue2: String
var myTestValue3: String
private override init() {
myTestValue = ""
myTestValue2 = ""
myTestValue3 = ""
super.init()
}
init(value: String, value2: String, value3: String) {
myTestValue = value
myTestValue2 = value2
myTestValue3 = value3
super.init()
}
}
Is there a better way to achieve this without having to duplicate the initialisation of the class variables?
Obviously, optionals are an option here but I don't want to go that route. Any suggestions for a more concise way to achieve the same?