I have some trouble to init()
a class in another class.
I've been looking if I can find a solution in here but I wasn't able to.
If I write super.init() there comes another error because the function isn't existing.
I don't know where I have to initialize it.
I'd prefer to init the Address
class in the open init from the Contact
class but if I do so I can't access the Address
class.
I think that it isn't a big mistake but I'm not able to find it.
open class Contact: Identifiable {
public var id: Int64?
var FirstName: String
var Name: String
var Phone: String
var Mail: String
var Birth: String
var News: Bool
open class Adress: Contact {
var Street: String
var Number: String
var PostalCode: String
var City: String
var Country: String // Error:'super.init' isn't called on all paths before returning from initializer
//If I add the Super.Init() there is an error because Super.Init() isn't existing and I don't know where to create it.
init(Street: String, Number: String, PostalCode: String, City: String, Country: String) {
self.Street=Street
self.Number=Number
self.PostalCode=PostalCode
self.City=City
self.Country=Country
}
}
public init(id: Int64, Firstname: String, Name: String, Phone: String, Mail: String, Birth: String, News: Bool) {
self.id = id
self.FirstName = Name
self.Name = Name
self.Phone = Phone
self.Mail = Mail
self.Birth = Birth
self.News = false
}
}