I'm making a subclass designated initializer with an extra parameter compared to the initializer from the superclass, however, i get an error. The code is:
class Pregunta: Codable {
var codImagen: String
var respCorrecta: Int
var respUsuario = -1
init(codImagen:String, respCorrecta:Int){
self.codImagen = codImagen
self.respCorrecta = respCorrecta
}
}
class PregRev: Pregunta {
var codAyuda: String
init(codImagen:String, respCorrecta:Int, codAyuda: String){
super.init(codImagen: codImagen, respCorrecta: respCorrecta)
self.codAyuda = codAyuda
}
}
And I get the error
'required' initializer 'init(from:)' must be provided by subclass of 'Pregunta'
What's the problem? I read that I just had to use a super.init with a superclass initializer. Thanks in advance.