This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5995-beginning-table-views/lessons/10
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5995-beginning-table-views/lessons/10
In place of the nested if statement I used a ternary operator to replace it.
Originally I had the following, but it didn’t work, because it’s just transposing the contents of the if statement onto the ternary operator.
cell.accessoryType == .none ? cell.accessoryType = .checkmark : cell.accessoryType = .none
// Error: Result values in '? :' expression have mismatching types '()' and 'UITableViewCell.AccessoryType'
Here’s what works instead:
cell.accessoryType = cell.accessoryType == .none ? .checkmark : .none
Credit goes to Google and SO: ios - Result values in '? :' expression have mismatching types '()' and 'Bool' - Stack Overflow
Hm.