最近想根据indexPaths删除单元格,所以该函数的输入参数是[IndexPath]
type,我需要将[IndexPath]根据 拆分成几个数组indexPath.section
,有什么简单的方法吗?例如
indexPaths =
[IndexPath(row: 0, section: 1),
IndexPath(row: 1, section: 1),
IndexPath(row: 2, section: 1),
IndexPath(row: 2, section: 0)]
想将其转换为
indexPath1 =
[IndexPath(row: 0, section: 1),
IndexPath(row: 1, section: 1),
IndexPath(row: 2, section: 1)]
indexPath0 =
[IndexPath(row: 2, section: 0)]
// maybe get a [Array]
[indexPath0, indexPath1]