Como uso o prepareForSegue rapidamente?
Eu tenho um ViewController com tableview chamado BasicPhrasesVC e quero passar os dados na célula selecionada para exibi-los no próximo ViewController (chamado BasicPhrasesVC).
class BasicPhrasesVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
let basicPhrases = ["Hello.","Goodbye.","Yes.","No.","I don't understand.","Please?","Thank you.","I don't know."]
var selectedBasicPhrase = ""
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return basicPhrases.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell")!
cell.textLabel?.text = basicPhrases[indexPath.row]
return cell
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
Não tenho certeza do que colocar aqui (quero passar a variável "selectedBasicPhrase")
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedBasicPhrase = basicPhrases[indexPath.row]
performSegueWithIdentifier("BasicPhrasesVC2BasicDisplayVC", sender: self)
}
}
Qualquer ajuda é apreciada.