Reputation: 199
Please help fast
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
}
The error is
Value of type 'UIViewController' has no member 'varView'
Upvotes: 1
Views: 7488
Reputation: 9226
change UIViewController with your destination view controller.
for e.g your destinationviewcontroller name is YourViewController
and also use if let for safely unwrap
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let DestVC = segue.destinationViewController as? YouViewController {
var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow!
DestVC.varView = indexPath.row
}
Upvotes: 3
Reputation: 27428
replace
var DestVC = segue.destinationViewController as UIViewController
with
var DestVC = segue.destinationViewController as YourDestinationClassName
and make sure that there is a varView
member available in that class
Hope this will help :)
Upvotes: 2