I am trying to update a label in my parent view (JL1EX3.swift) based on a buttonPressed event from my child view (inputPopUp.swift). I am aware I need to implement delegates/protocols for this to happen but am clueless as how to do so. Here's the code within my child view:
weak var parentView: JL1EX3!
var char: String!
var buttonPressed = String()
//Setter
func setChar(var thisChar: String){
char = thisChar
}
//Getter
func getChar()-> String{
if (buttonPressed == "addButton"){
char = "+"
}
if (buttonPressed == "minusButton"){
char = "-"
}
if (buttonPressed == "divideButton"){
char = "/"
}
if (buttonPressed == "multiplyButton"){
char = "*"
}
println(char)
return char
}
@IBAction func addButtonPressed(sender: AnyObject) {
buttonPressed = "addButton"
setChar("+")
getChar()
self.parentView.tapLabel.text = getChar() //Does not work - returns nil
self.removeAnimate()
}
Your help would be very much appreciated!!
weak var parentView: JL1EX3!