Beginning Table Views · Delegation | raywenderlich.com


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

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

1 Like

Hm. Screen Shot 2020-04-14 at 4.07.55 PM

@yby888 Do you still have issues with this?