Group Group Group Group Group Group Group Group Group

Beginning Table Views · Delegation | raywenderlich.com


#1

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5995-beginning-table-views/lessons/10

#2

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: https://stackoverflow.com/questions/41524938/result-values-in-expression-have-mismatching-types-and-bool/41525025


#3

@jsios Thank you for sharing your solution - much appreciated! :]