ho la seguente classe, con un metodo init:sottoclassi Swift - come ignorare Init()
class user {
var name:String
var address:String
init(nm: String, ad: String) {
name = nm
address = ad
}
}
Sto cercando di creare una sottoclasse questa classe, ma continuo a ricevere errori da parte super.init()
:
class registeredUser : user {
var numberPriorVisits: Int
// This is where things start to go wrong - as soon as I type 'init' it
// wants to autocomplete it for me with all of the superclass' arguments,
// and I'm not sure if those should go in there or not:
init(nm: String, ad: String) {
// And here I get errors:
super.init(nm: String, ad: String)
// etc....
L'iBook di Apple ha esempi di sottoclassi, ma nessuno include classi che hanno un metodo init()
con tutti gli argomenti effettivi. Tutti i loro init sono privi di argomenti.
Quindi, come si fa?
Penso che si possa (e si debba) rendere il codice più pulito dichiarando la classe in maiuscolo vero? – Anima