I have to functions, both of them trigger performSegueWithIdentifier
with the same segue. But depending of which function was called I need to pass different parameters in prepareForSegue
.
Some thing like
func first() {
// do some stuff
performSegueWithIdentifier("My segue", sender:AnyObject?)
}
func second() {
// do some stuff
performSegueWithIdentifier("My segue", sender:AnyObject?)
}
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "My segue" {
let destination = segue.destinationViewController as! MyController
if functionFirstWasCalled {
destination.property = value
} else if functionSecondWasCalled {
destination.property = anotherValue
}
}
}
Surely, I can do this by setting booleans from second() and first() and then checking them in prepareForSegue
- but maybe there is some more elegant way to do this ?