Monday 13 November 2017

Passing Data using Struct in between controller or method








We can pass value using "struct" in swift 3
  1. Create a swift file in your project
  2. Create a class in the swift file created like bellow
        class StructOperation {
          struct glovalVariable {
          static var userName = String();
         }
     }
  3. Assing value to "static var userName" variable of " struct glovalVariable" in "StructOperation" class from First View Controller like
     @IBAction func btnSend(_ sender: Any) {
        StructOperation.glovalVariable.userName = "Enamul Haque";
       //Code Move to Sencon View Controller
     }
  4. In destination view controller get value like bellow
     var username = StructOperation.glovalVariable.userName;



No comments:

Post a Comment