I keep running into a problem where addChild(myLabel)
is triggered twice, resulting in a crash. Is there a way to safeguard that addChild(myLabel)
isn't triggered if it has already added the label
?
I was looking for a bool
, something like myLabel.isAddedToView
but don't think there is one. I also tried
guard let test = addChild(myLabel) else {print("error") return}
But this gives me the error
Initializer for conditional binding must have Optional type, not Void'