Q:

Data not passing in Swift

I'm working on a journal app and now I want people to be able to click on a cell/entry and then go to a more detailed view where they can read/edit their entry. The thing is, the strings I'm trying to pass to the next view aren't coming through.
Edit:
This is the code on the TableViewController:
class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!

    let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
    var items: [Entry] = []
    var passedEntry:String = ""

    func fetchData() {

        do {
            items = try context.fetch(Entry.fetchRequest())
            print(items)
            DispatchQueue.main.async {
                self.tableView.reloadData()
            }
        } catch {
            print("Couldn't fetch data")
        }

    }

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

    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as UITableViewCell

        let date = items.reversed()[indexPath.row].date

        cell.textLabel?.text = items[indexPath.row].title

        if let date = date {
            let dateStamp = "Added on \(date)"
            cell.detailTextLabel?.text = dateStamp
        }

        return cell
    }

    @objc(tableView:editActionsForRowAtIndexPath:) func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

        let delete = UITableViewRowAction(style: .default, title: "Delete") { (action, indexPath) in
            // delete item at indexPath
            let item = self.items[indexPath.row]
            self.context.delete(item)
            (UIApplication.shared.delegate as! AppDelegate).saveContext()

            self.items.remove(at: indexPath.row)
            tableView.deleteRows(at: [indexPath], with: .fade)

        }

        return [delete]

    }

    public func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){

        if (segue.identifier == "showEntry") {
            // initialize new view controller and cast it as your view controller
            let viewController = EntryViewController()
            // your new view controller should have property that will store passed value
            viewController.passedEntry = passedEntry
        }
    }

    public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        passedEntry = items[indexPath.row].title!
        self.performSegue(withIdentifier: "showEntry", sender: self)

    }

    override func viewWillAppear(_ animated: Bool) {

        fetchData()

    }

This is the code on the EntryViewController which still prints nil:
class EntryViewController: UIViewController {

    var passedEntry:String!

    @IBOutlet weak var dreamTitle: UITextView!
    @IBOutlet weak var dreamPost: UITextView!
    @IBAction func saveChanges(_ sender: Any) {
    }

    override func viewWillAppear(_ animated: Bool) {
        print(passedEntry)
    }

I'm sorry for being a newbie, but I need some more detailed instructions...

A:

Two issues: 

The signature of prepareForSegue is wrong for Swift 3.
Never create view controllers with the default initializer when using storyboard

This main issue occurs in this line:
let viewController = EntryViewController()

You are creating a brand new instance of EntryViewController which is not the controller in the storyboard. You have to use the destination view controller of the segue:
  func prepare(for segue: UIStoryboardSegue, sender: Any?) {

   if segue.identifier == "showEntry" {
        // initialize new view controller and cast it as your view controller
        let viewController = segue.destination as! EntryViewController
        // your new view controller should have property that will store passed value
        let title = items[indexPath.row].title
        viewController.passedEntry = title
    }
  }

And I recommend to declare the string in the destination view controller as non-optional empty string rather than an implicit unwrapped optional. Non-optional types will never crash the app.
var passedEntry = ""

A:

You are defining prepareForSegue() as a local function inside the tableView-function. It will not be used. Put a debugger breakpoint into it and see yourself if it will be reached.

