我的代码有问题,它告诉我“无法分配给属性:'detailDic'是一个'let'常量”,我的构建失败
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
}
}
}
我试过这个,得到这个错误“运算符'=='的结果未使用”,它运行,但它会崩溃
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
}
}
}
1条答案
按热度按时间k2arahey1#
我发现了我的问题
我用了
let detailDic = [String:String]()
最多为
var detailDic = [String:String]()