LizG
LizG

Reputation: 2530

trying to go to next screen after user taps on cell in table

In a previous post, the below code was given as an answer to the question i have. When i tried using that code and replacing with my variables, etc I am getting an error.

'selectedValue' - error is "value of type ViewController has no member 'selectedValue'"

what does selectedValue represent?

override func prepareForSegue(segue: UIStoryboardSegue, sender:     AnyObject?) {
    if segue.identifier == "Details" {
        let destination = segue.destinationViewController as?     SecondViewController
        let cell = sender as UITableViewCell
        let selectedRow = tableView.indexPathForCell(cell)!.row
        destination!.selectedValue = items[selectedRow]
    }
}

Upvotes: 0

Views: 37

Answers (1)

paulvs
paulvs

Reputation: 12053

This code looks like the code you'd use to pass the selected data from one view controller to another when a cell is selected, am I right?

In your code, selectedValue should be a variable declared in SecondViewController. It is where you're passing the data to.

Upvotes: 1

Related Questions