ios - How to pass data when instantiating another view controller -


i'm beginner. doing popover when button pressed instantiates view controller user can select 5 choices. want able save sender.tag of button first view controller (where code snippet below came from) , pass second can save them parse. i'm not using segue can't pass way. in advance!

func showpopover(sender: uibutton) {        let vc = self.storyboard?.instantiateviewcontrollerwithidentifier("selectionviewcontroller")       vc!.modalpresentationstyle = .popover       vc!.preferredcontentsize = cgsizemake(150, 30)        if let presentationcontroller = vc!.popoverpresentationcontroller {          presentationcontroller.delegate = self          presentationcontroller.permittedarrowdirections = .up          presentationcontroller.sourceview = self.view          presentationcontroller.sourcerect = sender.frame           self.presentviewcontroller(vc!, animated: true, completion: nil)       }    } 

the easiest way declare variable var myvariable = int() outside of either view controller class. then, inside of main vc , before instantiate popover, save tag variable. you'll able use inside popover.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -