ios - how to pass json data other view controller -


hi getting data server i.e:

{     error = 0;    "error_msg" = "successfully login";   success = 1;    user =     {    driverid = 35;   drivername = "home  nath";  "com_id" = 2;  };  } 

now need pass data of drivername other view controller in label box.how one??

create variable of type string in destination view controller.

destinationviewcontroller.swift

class destinationviewcontroller: uiviewcontroller {      var drivername: string?      override func viewdidload() {         super.viewdidload()          print(drivername)      } } 

currentviewcontroller.swift

in currentviewcontroller override prepareforsegue:sender: method.

class currentviewcontroller: uiviewcontroller {      override func viewdidload() {         super.viewdidload()      }      override func prepare(for segue: uistoryboardsegue, sender: any?) {         let destnationvc = segue.destination as! destinationviewcontroller         destnationvc.drivername = "home nath"     }  } 

learn how pass data currentviewcontroller destinationviewcontroller , destinationviewcontroller orignviewcontroller ll lot.

refer passing data between view controllers.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -