这是我的代码:-
let selectedIndexPathAtCurrentSection = questionViewModel.selectedIndexPaths.filter({ $0.section == indexPath.section})
print(selectedIndexPathAtCurrentSection)
for indexPath in selectedIndexPathAtCurrentSection {
print(indexPath)
tableview.deselectRow(at: indexPath, animated: true)
if let indexOf = questionViewModel.selectedIndexPaths.index(of: indexPath) {
questionViewModel.selectedIndexPaths.remove(at: indexOf)
}
}
questionViewModel.selectedIndexPaths.append(indexPath)
print(questionViewModel.selectedIndexPaths)
print(indexPath)
因此,根据
何时选择该行。输出显示为:-
[[0,0]]
[[0,1]]
此输出将显示在questionViewModel.selectedIndexPaths
当我选择第二部分选项时,questionViewModel.selectedIndexPaths的输出将显示如下。
[[1,0]]
但是在选择每个部分时,我需要如下补充。
[[0,1],[1,0]]
如何实施?