I have some confusion with using a switch statement to a UITableView. I am attempting to set my numberOfRowsInSection function, but I am getting an error with my switch statement "Binary operator '~=' cannot be applied to operands of type 'Bool' and 'Int'':
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case section == 0:
return provinces.count
case section == 1:
return territories.count
default:
return 0
}
}
I am confused because section is declared as an Int, yet the error seems to indicate it is a BOOL. When i use an if-else statement, it compiles just fine:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 {
return provinces.count
} else {
return territories.count
}
}
What am I missing?