class ViewController: UIViewController, SCNSceneRendererDelegate, ChangeUserValueDelegate {
var currentUserValue:Bool = false
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
println(currentUserValue)
}
func changeUser(toValue:Bool) {
currentUserValue = toValue
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "mySegue"{
var yourNextViewController = (segue.destinationViewController as myViewController2)
yourNextViewController.delegate = self
println("hello")
}
}
}
protocol ChangeUserValueDelegate {
func changeUser(toValue:Bool)
}
class myViewController2: UIViewController,UIPickerViewDataSource,UIPickerViewDelegate {
var delegate:ChangeUserValueDelegate?
@IBAction func saveColor(sender: UIBarButtonItem) {
delegate?.changeUser(true)
self.navigationController?.popViewControllerAnimated(true)
}
}
When ViewController appears 'false' is printed even after clicking the saveColor button on myViewController2. On clicking saveColor, I need to return to ViewController and print 'true'. How do I get the segue working?