当我尝试将字典作为参数传递给子类中定义的方法时,出现了这个新的运行时错误。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell( withIdentifier: "cell", for: indexPath) as! Cell
cell.configure(self.data[indexPath.row] as Dictionary<String, AnyObject>) // FAILS HERE STATING: "Attempting to move out of a copy-on-write existential"
...
...
}
这曾经在 Swift 2.3 上运行得很好
如何解决这个问题?
PS:我在 Mac 10.12.6 上运行 Xcode 9.0(9A235)(使用 Swift 3.2)
最佳答案
最终使用[String: Any]
而不是Dictionary<String, AnyObject>
,它开始工作了。字典类型转换的奇怪问题。
关于swift - 尝试摆脱写时复制的存在主义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47350039/