Passing data between ViewControllers iOS swift
Solution 1:
In iOS it's easy to send a data from one view controller to other.If you navigate to the other view controller in that time you want to send a data to the viewController then declare a variable in the next view controller with any Data type like NSMutablearray,String,Int,Double or etc...
In the navigation time set the data to that variable like below and navigate
let secondController = self.storyboard?.instantiateViewControllerWithIdentifier("ViewController") as LoginViewController
secondController.array = self.array
self.navigationController?.pushViewController(secondController , animated: true)
In secondViewcontroller declare the array variable before the class implementation
var array :NSMutableArray!
In iOS it's easy to send a data from one view controller to other.If you navigate to the other view controller in that time you want to send a data to the viewController then declare a variable in the next view controller with any Data type like NSMutablearray,String,Int,Double or etc...
In the navigation time set the data to that variable like below and navigate
let secondController = self.storyboard?.instantiateViewControllerWithIdentifier("ViewController") as LoginViewController
secondController.array = self.array
self.navigationController?.pushViewController(secondController , animated: true)
In secondViewcontroller declare the array variable before the class implementation
var array :NSMutableArray!
Class LoginViewController:UIViewController {
}
Solution 2:
In other method you can save the data in the userdefaults and synchronize and get that in other ViewController
Comments
Post a Comment