Reputation: 7
I am trying to accomplish the following in Swift, but need some help.
It is a static table, when a cell is selected, I need it to save the text of that cell in a variable, and push to my next view. I am using the prepareForSegue method to do this. I've got it all working from passing previous variables forward, expect I'm stuck at this table.
In the below code, the variable 'key' is something else I also want to push forward.
Thanks.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "methodToConductorMaterial") {
var svc = segue.destinationViewController as ConMatViewController;
svc.key2 = key + TEXT OF TABLE CELL
}
}
Upvotes: 0
Views: 2646
Reputation: 15464
The sender parameter is your table view cell. So cast it to the cell and get the text from it:
let cell = sender as UITableViewCell
let text = cell.textLabel.text
Upvotes: 3