Reputation: 2682
I would like to update the button title (grey button) in the first interface controller by pressing on the blue button in the second interface controller.
I was able to use the counter in order to update the label, but how would I do to send the result back to the first interface Controller
should it be executed in the second interface controller and then the result is sent back through the push segue
How would I use pushControllerWithName("secondController",context: ... )
Should I do something like that:
var counter = 1
@IBAction func addOne() {
greyButtonLabel.setTitle("\(counter++)")
pushControllerWithName("secondController", context : add)
}
// The second interface controller
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
if let addone = context as? counter {
greyButtonLabel.setTitle("\(counter++)")
}
}
Upvotes: 3
Views: 711
Reputation: 8538
You cannot change a UI element in the first interface controller when it is not active.
Here is one possible way:
self
of the first interface controller to the second one (using pushControllerWithName("secondController", context: ... )
).popController
method.willActivate
).Upvotes: 1