0

I am endeavouring to master segues and have created to simple view controllers, the first being a simple TableViewController using the following class

import UIKit

class CourseTVC: UITableViewController {

    var courseVenue = ["Cardiff", "Swansea", "Rhyl", "Bangor"]

    var courseDate = ["27th February 2017", "9th March 2017", "17th March 2017", "23rd March 2017"]

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return courseVenue.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "courseCell", for: indexPath)
        cell.textLabel?.text = courseVenue[indexPath.row]
        cell.detailTextLabel?.text = courseDate[indexPath.row]
        return cell
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "showMapDeail" {
            let destinationController = segue.destination as! CourseMapVC
            if let indexPath = tableView.indexPathForSelectedRow {
                destinationController.courseTitle = courseVenue[indexPath.row]


            }
        }
    }
}

I am using simple script arrays to populate the cell data. This works well and I want to pass the selected row title to a second ViewController and simply display the venue title. The second view controller opens up (the segue is named showMapDetail on the storyboard and is a show segue) but displays no venue title. The class for the second view controller is thus

import UIKit

class CourseMapVC: UIViewController {

    @IBOutlet weak var venueTitle: UILabel!

    var courseTitle: String = ""

    override func viewDidLoad() {
        super.viewDidLoad()

        venueTitle.text = courseTitle
    } 
}

There are no errors and no data passed or nil value passed. There seems to be clue that i can interrogate further, so any pointers greatly received.

thanks.

Bowcaps
  • 127
  • 2
  • 11

1 Answers1

0

Sorry Guys, as soon as I posted this I noticed a typo in the segue identifier.

Thanks anyways.

Bowcaps
  • 127
  • 2
  • 11