Reputation: 139
This is my code.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0{
self.navigationController?.pushViewController(self.storyboard?.instantiateViewControllerWithIdentifier("History") as! History, animated: true)
TV.deselectRowAtIndexPath(indexPath, animated: false)
}
}
I push to another ViewController(named History) and I want to pass my value which is in this ViewController to History ViewController.
I know we can pass value by using segue and segue's destinationViewController and sourceViewController.
But there is no segue in this case.
So,I don't know how to assign a var's value to History's var.
Anybody can help me?
Upvotes: 1
Views: 36
Reputation: 3690
let history = self.storyboard?.instantiateViewControllerWithIdentifier("History") as! History
//Here U can Access the variable of History
history.yourVar=Assign Value
self.navigationController?.pushViewController(history, animated: true)
TV.deselectRowAtIndexPath(indexPath, animated: false)
Upvotes: 4