classViewController:UIViewController{letitemsSource=["items1","items2","items3","items4","items5","items6","items7","items8"]varitems:[String]=[]@IBOutletweakvarsegmentedControl:UISegmentedControl!@IBOutletweakvartableView:UITableView!overridefuncviewDidLoad(){super.viewDidLoad()// Do any additional setup after loading the view.tableView.dataSource=selfitems=itemsSource}}extensionViewController:UITableViewDataSource{functableView(_tableView:UITableView,numberOfRowsInSectionsection:Int)->Int{returnitems.count}functableView(_tableView:UITableView,cellForRowAtindexPath:IndexPath)->UITableViewCell{letcell=tableView.dequeueReusableCell(withIdentifier:"testCell")!cell.textLabel?.text=items[indexPath.row]returncell}}