Can't pass through data to second controller with segue

can definition
can synonym
can y
can-am
can bus
can airport
cant
can band

I can't get a simple segue to work when a cell in a tableview gets pressed. It does go to the next view after I tapped two different items. But I can't pass any values from the first controller to the second. If I set a value to the label in the second controller and load it in the viewDidLoad method it shows up.

I'm going crazy as I've been trying to get this work for ages....

My storyboard: https://snag.gy/DCw9MU.jpg

CategoryListViewController(1st controller):

import Foundation
import UIKit

class CategoryListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!

    var categoryList = TestData.sharedInstance.categoryList


    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.title = "iEngineer"
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.tableView .reloadData()
        tableView.dataSource = self
        for category in categoryList{
            print(category)
        }

    }

    // MARK: - Segues
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "showFormulaList" {
            if let indexPath = tableView.indexPathForSelectedRow {
                let category = self.categoryList[indexPath.row]
                let formulaListViewController = (segue.destination as! UINavigationController).topViewController as! FormulaListViewController
                formulaListViewController.text = category
                formulaListViewController.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
                formulaListViewController.navigationItem.leftItemsSupplementBackButton = true
            }
        }

    }

    // MARK: - Table View
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }


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

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "categoryCell", for: indexPath)
        let object = categoryList[indexPath.row]
        cell.textLabel!.text = object
        return cell
    }

    func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
        performSegue(withIdentifier: "showFormulaList", sender: self)
    }
}

FormulaListViewController(2nd controller):

import Foundation
import UIKit

class FormulaListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {


    @IBOutlet weak var titleLabel: UILabel!

    var formulaList = TestData.sharedInstance.formulaList

    var fSwift: String!


    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.title = "iEngineer"
        print(fSwift)
        titleLabel.text = fSwift

    }

    // MARK: - Table View
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

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

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "formulaCell", for: indexPath)
        let object = formulaList[indexPath.row]
        print(object)
        cell.textLabel!.text = object
        return cell
    }
}

Where is my mistake or what am I doing wrong?

I greatly appreciate any help

You need didSelectRowAt instead of didDeselectRowAt

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    performSegue(withIdentifier: "showFormulaList", sender: self)
}

Also make sure segue source is the vc not the cell , and since you fire the segue in didDeselectRowAt this

if let indexPath = tableView.indexPathForSelectedRow 

will be nil

Can, Can may refer to: Contents. 1 Containers; 2 Music; 3 Other; 4 See also. Containers[edit]. Aluminum can · Drink can · Oil can · Steel and tin cans · Trash can  Can definition, to be able to; have the ability, power, or skill to: She can solve the problem easily, I'm sure. See more.

You have used didDeselectRowAt:

func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
        performSegue(withIdentifier: "showFormulaList", sender: self)
}

You need to use didSelectRowAt:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
            performSegue(withIdentifier: "showFormulaList", sender: self)
}

The Official CAN / Spoon Records Website, VerbEdit. can (third-person singular simple present can, present participle -, simple past could, past participle (obsolete except in adjectival use) couth). Define can. can synonyms, can pronunciation, can translation, English dictionary definition of can. to be able to, have the power or skill to: I can take a bus to the

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    performSegue(withIdentifier: "showFormulaList", sender: self)
}

You should use didSelect instead of didDeselectRowAt, also you should pass something better than self, because with self you are passing the entire CategoryListViewController Try to pass the indexPath like this

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    performSegue(withIdentifier: "showFormulaList", sender: indexPath)
}

and change the function prepare in this

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "showFormulaList" {
        if let indexPath = sender as? IndexPath {
            let category = self.categoryList[indexPath.row]
            let formulaListViewController = (segue.destination as! UINavigationController).topViewController as! FormulaListViewController
            formulaListViewController.fuckSwift = category
            formulaListViewController.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
            formulaListViewController.navigationItem.leftItemsSupplementBackButton = true
        }
    }

}

If this doesn't help you try to debug your code and find where you lost your variable :)

Can, can meaning: 1. to be able to: 2. used to say that you can and will do something: 3. to be allowed to: . Learn more. can definition: 1. to be able to: 2. used to say that you can and will do something: 3. to be allowed to: . Learn more.

can, 1.4Used to indicate that something is typically the case. 'antique clocks can seem out of place in modern homes'. More example sentences. 110 synonyms of can from the Merriam-Webster Thesaurus, plus 97 related words, definitions, and antonyms. Find another word for can. Can: to bring (as an action or operation) to an immediate end.

CAN, A fitness trainer who worked for Anytime Fitness in Wauwatosa, Wisconsin, has been fired after promoting an "I Can't Breathe" workout,  Find the latest Canaan Inc. (CAN) stock quote, history, news and other vital information to help you with your stock trading and investing.

Can, can. (kæn). n. 1. a container, esp for liquids, usually of thin sheet metal: a petrol can;  Can (stylised as CAN) was a German experimental rock band formed in Cologne in 1968 by the core quartet of Holger Czukay (bass, tape editing), Irmin Schmidt (keyboards), Michael Karoli (guitar), and Jaki Liebezeit (drums).