My Scenario, I am loading JSON data into tableView, whenever I am trying to click tableView custom cell I am getting cell indexPath.row data. Now, I am trying to pass particular cell array data to another viewcontroller. Here, I need to verify below code is correct one or not and also how to get all the values from array and to show on labels in second viewcontroller?
Here below code to passing array value one to another viewcontroller
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(self.tableArray[indexPath.row])
tableView.deselectRow(at: indexPath, animated: true)
let smallVC = storyboard!.instantiateViewController(withIdentifier: "popupview") as! PopupViewController
let item = tableArray[indexPath.row]
smallVC.array = [item]
present(smallVC, animated: true, completion: nil)
}
Second ViewController
var array = [Datum]() //Datum decodable root
override func viewDidLoad() {
super.viewDidLoad()
print(“DATA: \(array)") //here, i need to get all values and assign label.
}
My Output
DATA: [parseJSON.Datum(catID: "3", catName: "Cars", catParentid: "2", name: “jhon”, year: "3000", fullname: parseJSON.Fullname(firstname: "jio", lastname: "jack"), address: parseJSON.Address(city: "sanfrancisco", state: "california"), ship: parseJSON.Ship(captian: "mojo", time: "12.30.01"))]