When creating an instance using the convenience initialiser the playground keeps giving me this error "error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=2, address=0x7ffee5ae9ff8)" however when using the designated initialiser it works fine.
I'm not entirely sure if i'm setting the convenience initialiser correctly so that only the arsenal parameter is required when creating a new instance.
class FootballTeams {
var liverpool: String
var chelsea: String
var manchesterunited: String
var arsenal: String = "fourth"
init(arsenal:String, chelsea:String,
liverpool: String, manchesterunited:String ) { //designated initialiser
self.arsenal = arsenal
self.chelsea = chelsea
self.liverpool = liverpool
self.manchesterunited = manchesterunited
}
convenience init(arsenal: String){
self.init(arsenal: arsenal) //call to designated initialiser above
self.arsenal = arsenal
}
}
let properInstance = FootballTeams(arsenal: "Overides stored property value", chelsea: "a", liverpool: "b", manchesterunited: "b")
print(properInstance.arsenal)
let convenienceInstance = FootballTeams(arsenal: "This is an instance from the convenience init")
print(convenienceInstance.arsenal)