Do you want two tables that each scroll independently? (maybe side by side?) Or do you want to include two sets of data in a single table so that you have to scroll past one to see the other?
If you want to have just two different set of data show in the same table but separated, you can create two sections. This page has a really good overview:
https://developer.apple.com/documentation/uikit/uitableview
You'll want to implement these methods in your UITableViewController
:
var mydata = [["siamese", "tabby", "orange", "persian"],
["wolfhound", "labrador", "german shepherd"]]
override func numberOfSections(in tableView: UITableView) -> Int {
return mydata.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return mydata[section].count
}
Each of the methods that has a section variable should lookup the data for that section and return the right information.
If you want two tables that scroll independently of each other, you will need to create a UIViewController
and have two models for the data and return the right one for the correct table. Create IBOutlet for each of the tables, and set the delegate and datasource for each with the right data.
This question asks about UIPicker with two data sources - you can do something very similar with your tables: https://stackoverflow.com/a/55527743/9878866