I have swift file has this codes
Data.swift
class Data {
class Entry {
let filename: String
let heading: String
let dates: String
init(fname: String, heading: String, dates: String) {
self.heading = heading
self.filename = fname
self.dates = dates
}
}
let places = [
Entry(fname: "bridge.jpeg", heading: "Heading 1", dates: "26/04/2016"),
Entry(fname: "mountain.jpeg", heading: "Heading 2", dates: "26/04/2016"),
Entry(fname: "snow.jpeg", heading: "Heading 3", dates: "26/04/2016"),
Entry(fname: "sunset.jpeg", heading: "Heading 4", dates: "26/04/2016")
]
}
I managed to access it on TableView like this
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as PlacesTableViewCell
let entry = data.places[indexPath.row]
let image = UIImage(named: entry.filename)
cell.bkImageView.image = image
cell.headingLabel.text = entry.heading
cell.dateLabel.text = entry.dates
return cell
}
but Outside the TableView in another file "ViewController" I didn't know how to access it "dates" and convert it to NSDate ?!