ios - Pass data to two tab bar view controllers -
i trying pass data first view controller 2 other view controllers, in tab bar, have been struggling trying through prepareforsegue
. code @ 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 tried pass data first view controller first tab, , second tab, didn't have success either.
anyone have suggestions? current code returns error: fatal error: array index out of range
on second last line.
thanks!
figured out. had change code this:
var tabcontroller1 = segue.destinationviewcontroller as! uitabbarcontroller var navcontroller1 = tabcontroller1.viewcontrollers![1] as! uinavigationcontroller var destcontroller1 = navcontroller1.viewcontrollers[0] as! mapviewcontroller destcontroller1.parkpassed = parkselected
i had stupidly forgot change of variable names, , had change index of nav controller's view controller.
Comments
Post a Comment