У меня есть одна переменная, usernameSelected
, которую я хочу отправить второму VC.
Первый VC:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let usernameSelectedRow = picUsernameArray[indexPath.row]
usernameSelected = usernameSelectedRow
print(usernameSelectedRow) --> [this prints the right data]
print(usernameSelected) --> [this prints the right data]
performSegue(withIdentifier: "goToProfileSelected", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "goToProfileSelected" {
let destination = segue.destination as?
OtherUserProfileViewController
print(usernameSelected) ---> [this prints nil!!!!]
destination!.usernameValue = usernameSelected ---> [this returns nil to second VC]
}
}