On the click of a button I load my tableview like so...
class MyViewController: UIViewController {
@IBOutlet weak var tableview: UITableView!
var tableConfig : TableViewConfig<Company, CompanyCell>?
private var tabledata = [Company]() {
didSet {
tableConfig?.items = tabledata
}
}
// MARK: - View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
configureTableView()
}
private func configureTableView() {
let cellIdentifier = String(describing: CompanyCell.self)
tableview.register(UINib(nibName: cellIdentifier, bundle: Bundle.main), forCellReuseIdentifier: cellIdentifier)
tableConfig = TableViewConfig<Company, CompanyCell>(tableview, items: tabledata, cellIdentifier: cellIdentifier, configClosure: { object, cell in
cell.configureCompany(object)
})
tableConfig?.selectedRow { indexPath in
// Call Delegate Action
if let index = indexPath?.row {
let company = self.tabledata[index]
self.tabledata[index] = company
self.tableConfig?.items = self.tabledata
self.tableview.reloadRows(at: [indexPath!], with: .automatic)
}
}
tableview.dataSource = tableConfig
tableview.delegate = tableConfig
}
}
Here, in this line...var tableConfig : TableViewConfig<Company, CompanyCell>?
, the Company
and CompanyCell
are names of the model and UITableViewCell respectively.
What I want is that on the click of the button, while loading MyViewController
(i.e. the viewcontroller given above), I want to pass the model name and the tableviewcell name. But how to pass the model name from one viewcontroller to the other, I can't figure out.
I have tried this, this and this link. But it didn't help.
Hope somebody can help...