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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -