Reputation: 97
So I have multiple buttons on one view segue'ing to other views. I have the function prepareForSegue()
at the bottom of my code preparing one segue, however the app crashes when I use another segue on the view, even if it doesn't need any preparing.
I think that the problem is that all of the segues use the prepareForSegue()
function, however the storyboard ID is different than the view it is transitioning to.
Is there any way to specify a prepareForSegue()
function for each separate segue on the same view?
Code:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let theVC: ViewController = segue.destinationViewController as! ViewController
theVC.receivedString = "true"
}
Thanks
Upvotes: 0
Views: 97
Reputation: 9346
In your prepareForSegue you should use a condition to check segue identifier like:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "yourSegueToAnyController")
{
//do code for specific viewController
}
}
Upvotes: 1