I have created 2 TableViewControllers in one ViewController programmatically as :
// contents for labels in cells for tableviewcontrollers
let contents1 : [String] = ["One:","Two:","Three:","Four:","Five:"]
let contents2 : [String] = ["Six:","Seven:","Eight:","Nine:","Ten:"]
override func viewDidLoad() {
super.viewDidLoad()
table1.delegate = self
table1.dataSource = self
table2.delegate = self
table2.dataSource = self
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if(tableView.tag == 1)
{
return contents1.count
}
else if (tableView.tag == 2)
{
return contents2.count
}
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath as IndexPath )
if (tableView.tag == 1)
{
cell.textLabel?.text = contents1[indexPath.row]
}
else if (tableView.tag == 2)
{
cell.textLabel?.text = contents2[indexPath.row]
}
return cell
}
My question is that , how can I programmatically link "Four:" label of first TableViewController "table1" when selected to show up next new ViewController without using Segue?