【发布时间】:2017-08-01 13:50:35
【问题描述】:
我的代码有什么问题?我一直收到这个错误,我不知道为什么它说方法不能是 @objc 覆盖,因为参数 2 的类型不能在 Objective-C 中表示。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
let vc = segue.destinationViewController as! MovieViewController
if let indexPath = self.tableView.indexPathForSelectedRow{
let item = TableData[indexPath.row]
vc.senddMovie = item
}
}
【问题讨论】:
-
您在哪一行收到此错误
-
在覆盖函数准备的第 1 行
-
你把
@objc放在你上面的班级哪里? -
您使用的是什么版本的 Xcode?我可以找到消息 因为参数 2 的类型不能在 Objective-C 中表示 仅在 Swift 2 中。
-
您使用的是什么版本的 Xcode?在 8.2.1 中,
segue.destinationViewController现在是segue.destination,所以我怀疑您使用的是旧版本。
标签: swift