I am trying to pass some data from my first view controller to two other view controllers, however as they are in a tab bar, I have been struggling with trying to do this through prepareForSegue
. This is my code at the moment:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "showRides") {
var tabController = segue.destinationViewController as! UITabBarController
var navController = tabController.viewControllers![0] as! UINavigationController
var destController = navController.viewControllers[0] as! InitalViewController
destController.parkPassed = parkSelected
var tabController1 = segue.destinationViewController as! UITabBarController
var navController1 = tabController.viewControllers![1] as! UINavigationController
var destController1 = navController.viewControllers[1] as! MapViewController
destController1.parkPassed = parkSelected
}
}
I have also tried to pass the data from the first view controller to the first tab, and then to the second tab, but I didn't have any success with this either.
Anyone have any suggestions? That current code returns the error: fatal error: Array index out of range
on the second to last line.
Thanks!