Expandable table menu to new View Controller in Xcode

I hava a really big problem. How can I link the menu name "Canada" in my expandable table menu to a new View Controller named "Canada", and then the menu name "Denmark" to a View Controller named "Denmark" and so on in my Xcode-project?

Here is my code. I have search the entire web for solutions.

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, ExpandableHeaderViewDelegate {

@IBOutlet weak var tableView: UITableView!

var sections = [

Section(genre: "North America",

menytitel: ["USA", "Canada"],

expanded: false ),

Section(genre: "Europe",

menytitel: ["Sweden", "Finland", "Denmark", "Ireland"],

expanded: false ),

Section(genre: "Africa",

menytitel: ["Egypt", "Marocko"],

expanded: false ),


override func viewDidLoad() {

super .viewDidLoad()

// Do any additional setup after loading the view, typically from a nib.

tableView.delegate = self

tableView.dataSource = self


override func didReceiveMemoryWarning() {

super .didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.


func numberOfSections(in tableView: UITableView) -> Int {

return sections.count


func tableView( _ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

return sections[section].menytitel.count


func tableView( _ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {

return 44


func tableView( _ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

if (sections[indexPath.section].expanded) {

return 44

} else {

return 0



func tableView( _ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {

return 2


func tableView( _ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

let header = ExpandableHeaderView()

header.customInit(title: sections[section].genre, section: section, delegate: self )

return header


func tableView( _ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell")!

cell.textLabel?.text = sections[indexPath.section].menytitel[indexPath.row]

return cell


func toggleSection(header: ExpandableHeaderView, section: Int) {

sections[section].expanded = !sections[section].expanded


for i in 0 ..< sections[section].menytitel.count {

tableView.reloadRows(at: [IndexPath(row: i, section: section)], with: .automatic)





Question is probably better asked over on the Apple Developer forums. This questions is about the Apple frameworks, not Swift.