I am new to Swift Programming and I am having problems. So what I want to do is when the user selects the row in a table then I want to grab the selected row's title and then pass it to the next View Controller. Here is my code for the First View Controller:
let senderArray = ["Sogyal","Ram"]
let messageArray = ["Hello","What's up?"]
cell.senderName.text = senderArray[indexPath.row]
cell.senderMessage.text = messageArray[indexPath.row]
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
newIndex = indexPath.row
let selectedMessage = messageArray[indexPath.row]
let composeVC = ComposeMessageVC()
composeVC.usernameLbl = selectedMessage
tableView.deselectRow(at: indexPath, animated: true)
performSegue(withIdentifier: "goToComposeM", sender: self)
}
Any help would be appreciated.