I literally changed none of the code, but after updating to Xcode 12, the prepare for Segue method to pass Data doesn't work anymore.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toDetails" {
if let indexPath = sender as? IndexPath, let nextVC = segue.destination as? JobDetailViewController {
nextVC.jobDetails =
JobDetailViewController.JobDetails(jobDetail: jobs[indexPath.row].text, userName: jobs[indexPath.row].addedByUser!, jobImage: jobs[indexPath.row].jobImage, downloadURL: jobs[indexPath.row].downloadURL!)
}
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "toDetails", sender: indexPath.row)
}
DetailedVC:
var jobDetails: JobDetails?
struct JobDetails {
var jobDetail: String
var userName: String
var jobImage: UIImage?
var downloadURL: String?
}
(for example) By print("Hello (jobDetails?.userName)") I'm getting "Hello nil" as output
Did anything has been changed with the new Swift/Xcode version? I'm also not getting any errors/warnings
Please have a look, you are passing indexPath.row which is Int and in prepare you are parsing it to IndexPath.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "toDetails", sender: indexPath)
}