Skip to content

Instantly share code, notes, and snippets.

@rockname
Created December 3, 2018 08:45
Show Gist options
  • Select an option

  • Save rockname/0dc9d9c177cdbf8cf054fc64ca31116b to your computer and use it in GitHub Desktop.

Select an option

Save rockname/0dc9d9c177cdbf8cf054fc64ca31116b to your computer and use it in GitHub Desktop.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
return tableView.dequeueReusableCell(withIdentifier: "ProfileTableViewCell") as! ProfileTableViewCell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "TaskTableViewCell") as! TaskTableViewCell
let personalTask = tasks.filter { $0.category == .personal }[indexPath.row]
cell.configure(with: personalTask)
return cell
case 2:
let cell = tableView.dequeueReusableCell(withIdentifier: "TaskTableViewCell") as! TaskTableViewCell
let shoppingTask = tasks.filter { $0.category == .shopping }[indexPath.row]
cell.configure(with: shoppingTask)
return cell
case 3:
let cell = tableView.dequeueReusableCell(withIdentifier: "TaskTableViewCell") as! TaskTableViewCell
let workTask = tasks.filter { $0.category == .work }[indexPath.row]
cell.configure(with: workTask)
return cell
default:
fatalError()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment