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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -