I'm not sure I understood what exactly is your problem. But if you need to access that data on the second view controller, the simplest way would be to inject that data into the DetailsViewController
you're instantiating when the cell is selected.
But first you need to create that property:
class DetailsViewController: UIViewController {
var data: JSON?
...
}
Then when instantiating that view controller:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let vc = storyboard?.instantiateViewController(withIdentifier: "DetailsViewController") as? DetailsViewController else { return }
vc.data = data[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
}
Now you can use that data on your DetailsViewController
to pull any information you need from the json response:
class DetailsViewController: UIViewController {
...
override viewDidLoad() {
super.viewDidLoad()
let title = data["title"]
...
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…