I have issue with my code, it tells me "Cannot assign to property: 'detailDic' is a 'let' constant" and my build failed
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "detail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let dic = cities[indexPath.row]
let detailVC = segue.destination as! DetailViewController
detailVC.detailDic = dic
}
}
}
I've tried this and got this error "Result of operator '==' is unused" and it runs but it will be crash
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "detail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let dic = cities[indexPath.row]
let detailVC = segue.destination as! DetailViewController
detailVC.detailDic == dic
}
}
}
i found my problem
i used let detailDic = [String:String]()
that most be var detailDic = [String:String]()