0

I'm new to swift and I've been stuck on this for a while now I'm trying to pass a Struct Array from a tableview cell to another view

1 Answer 1

1

If you want to share specific cell's data into table of other view controller, then you need to create an object of Model struct rather than its array just like below:

var newFeed: Model?

Next you can assign it value of particular cell before navigation in main did select method as below:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    guard let vc = storyboard?.instantiateViewController(withIdentifier: "Comment") as? Comment else {return}
    vc.newFeed = getInfo[indexPath.row]
    navigationController?.pushViewController(vc, animated: true)
}

It will assign that cell's data to newFeed Variable and relaod table with that data.

For any question, feel free to ask.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.