ios - Swift: How to send data from loginView to other views? -


i have loginview , can switch other views slide-out-menu swrevealcontroller.

the storyboard looks this: http://imgur.com/a/qx3tj

i token alamofire in loginviewcontroller , want send mainpageview prepareforsegue

override func prepare(for segue: uistoryboardsegue, sender: any?) {     if (segue.identifier == "loginsegue") {         personresource.gettoken(username: usernametf.text!, password: passwordtf.text!){ token in             let mainpagevc = segue.destination as! mainpageviewcontroller                             mainpagevc.token = token         }     } } 

when click on login error:

unrecognized selector sent instance

what proper way this?

can change login code this:

func login(){          personresource.gettoken(username: usernametf.text!, password: passwordtf.text!){ token in                         if let t = token as? string{                             performsegue(with:"loginsegue", sender:token)                         }                 } } 

and after retrieve token api you'll perform segue "loginsegue"

and need modify prepare function:

override func prepare(for segue: uistoryboardsegue, sender: any?) {     if (segue.identifier == "loginsegue") {         if let token = sender as? string{                     let mainpagevc = segue.destination as! mainpageviewcontroller                           mainpagevc.token = token                 }     } 

basically need perform segue after retrieve token.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -