I'd like to pass an array of class types as parameter to a function, how can I do that?
Code:
let classList = [Class1.self, Class2.self, Class3.self]
myFunction(classList) // how would I write the parameter for this?
Goal:
I created a UITableView extension to shorten registering nibs and you can call it using tableView.register(CellClass.self). The function signature is func register<T>(_ cellType: T.Type)
Given that, I'm trying to create a register cells function where I want to do something like this:
func registerCells(classTypes: [XXXX]) {
classTypes { (classType) in
tableView.register(YYYY)
}
}
and call it using tableView.resigterCells([Class1.self, Class2.self, Class3.self])
I'm not sure if this is possible in Swift. Please advise :)
[UITableViewCell.Type], then?