Catalyst - Impossible to pre-select multiple cells of an UITableView under macOS

Description:
In an iOS / iPad / tvOS / macOS application, under macOS it's impossible to pre-select several cells of the same UITableView.
Visually only one cell is checked and the tableView.indexPathsForSelectedRows property has always only one element.

Instruction:
  • Create a UITaleView with custom cell and several sections

  • tableView.allowsMultipleSelection = true

  • In the custom cell, overload setSelected to show a .checkmark or .none

  • In awakeFromNib of the custom cell define selectionStyle to .none

  • In cellForRowAt of the tableview define cells to pre-select, example first cell of each section:

Code Block
if (indexPath.row == 0) {
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
} else {
tableView.deselectRow(at: indexPath, animated: false)
}
  • > Run

Expected result:
Cells visually selected AND indexPathsForSelectedRows reflecting this selection

Obtained result:
Only the last cell called by tableview.selectRow is selected and present in the property indexPathsForSelectedRows

Did you find a solution to have cell preselected and have property indexPathsForSelectedRows representing the display ?

Thanks for your help !
Is the UITableView in “edit mode”? allowsMultipleSelectionDuringEditing Would also need to be true in this situation.
Hello,

Yes I tried but the result is still inconsistent between iOS & macOS.
I just push a POC with a screenshot, am i doing something wrong?

Demo

Thanks !

I can reproduce this behavior and as of now unfortunately there isn't a good workaround. It would be great if you could file this via the feedback assistant and include your sample project.
Catalyst - Impossible to pre-select multiple cells of an UITableView under macOS
 
 
Q