How do I pass indexPathForSelectedRow into a UITabView via a UITabBarController?

Clash Royale CLAN TAG#URR8PPPHow do I pass indexPathForSelectedRow into a UITabView via a UITabBarController?
I'm trying to segue from a UITableView to a specific tab within a UITabBarController. While googling, I found two sets of info that seem to indicate how to do, but neither were using a UITableView as the source.
UITableView
UITabBarController
UITableView
The first source is this wonderfully written answer I found here on StackOverflow: How to make a segue to second item of tab bar?
The second source was this site: http://www.codingexplorer.com/segue-uitableviewcell-taps-swift/
I have been attempting to combine the two for my app. Below is a truncated version of my originating UIViewController (I can post the full one if needed, just most the code isn't related to this segue, I don't think):
class BonusListViewController: UITableViewController {
// MARK: - Table View Configuration
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if isFiltering() {
print("Showing (filteredBonuses.count) Filtered Results")
return filteredBonuses.count
}
print("Found (bonuses.count) rows in section.")
return bonuses.count
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRow(at: indexPath as IndexPath, animated: true)
let row = indexPath.row
}
private var nextViewNumber = Int()
@IBAction func secondView(_ sender: UITapGestureRecognizer) {
self.nextViewNumber = 2
self.performSegue(withIdentifier: "tabBar", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "tabBar" {
let destination = segue.destination as! TabBarViewController
switch (nextViewNumber) {
case 1:
destination.selectedIndex = 0
case 2:
destination.selectedIndex = 1
if self.isFiltering() {
destination.bonus = filteredBonuses[(tableView.indexPathForSelectedRow?.row)!]
} else {
destination.bonus = bonuses[(tableView.indexPathForSelectedRow?.row)!]
}
default:
break
}
}
}
}
My issue resolves around trying to pass the tableView.indexPathForSelectedRow?.row over to the UITabViewController. In the prepare(for segue) near the end of the above code snippet I'm getting a compile error for the destination.bonus = lines that says,
tableView.indexPathForSelectedRow?.row
UITabViewController
prepare(for segue)
destination.bonus =
Value of type 'TabBarViewController' has no member 'bonus'
This is technically true as I'm just trying to pass through the TabBarViewController to the second tab it controls.
How can I fix the above to let me tap on a cell, and then pass the selected row over to the target UITabView?
UITabView
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.