ios - Swift pass data through navigation controller -
one of segues transitions view controller tableview controller. want pass array between two, navigation controller before tableview controller, can't figure out how pass array. how pass data through navigatiom controller tableview controller?
override prepareforsegue , set whatever value on tableview you'd like. can grab tableview uinavigation viewcontrollers property.
override func prepareforsegue(segue: uistoryboardsegue!, sender: anyobject!){ let navvc = segue.destinationviewcontroller uinavigationcontroller let tablevc = navvc.viewcontrollers.first yourtableviewcontrollerclass tablevc.yourtableviewarray = localarrayvalue } for swift 3 :
override func prepare(for segue: uistoryboardsegue, sender: any?) { let navvc = segue.destination as? uinavigationcontroller let tablevc = navvc?.viewcontrollers.first as! yourtableviewcontrollerclass tablevc.yourtableviewarray = localarrayvalue }
Comments
Post a Comment