We can pass value using "struct" in swift 3
- Create a swift file in your project
- Create a class in the swift file created like bellow
class StructOperation { struct glovalVariable { static var userName = String(); } }
- 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 }
- In destination view controller get value like bellow
var username = StructOperation.glovalVariable.userName;
No comments:
Post a Comment