请快速帮助
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var DestVC = segue.destinationViewController as UIViewController
var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow!
DestVC.varView = indexPath.row // This is the error line
}
错误是
类型的价值' UIViewController'没有会员' varView'
答案 0 :(得分:3)
使用目标视图控制器更改UIViewController。
例如,您的destinationviewcontroller名称为YourViewController
并且如果让安全打开
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let DestVC = segue.destinationViewController as? YouViewController {
var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow!
DestVC.varView = indexPath.row
}
答案 1 :(得分:2)
替换
var DestVC = segue.destinationViewController as UIViewController
与
var DestVC = segue.destinationViewController as YourDestinationClassName
并确保该班级中有varView
个成员
希望这会有所帮助:)