I am learning the new Swift programming language and I would like to know how can I pass data from a CollectionViewController to a TableViewController.
My objective is that everytime someone taps one of the cells in the CollectionViewController, this actions takes them to the TableViewController where a list of images related to the selected cell appears.
CollectionViewController.swift
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "listSegue") {
if let indexPath = self.menuCollection.indexPathsForSelectedItems() {
let control = (segue.destinationViewController) as TableViewCell
control.cellImage.image = UIImage(named: sectionImages[indexPath])
}
TableViewCell.swift
class TableViewCell: UITableViewCell {
@IBOutlet weak var cellImage: UIImageView!
}
TableViewController.swift
Do I have to put some code here??
Please help me I would really appreciate it :) Thank you :)