Recently I want to delete cells according to indexPaths, so the input parameter of the function is [IndexPath]
type, I need to split the [IndexPath] to several arrays according to the indexPath.section
, is there any easy way to do this?
For example
indexPaths =
[IndexPath(row: 0, section: 1),
IndexPath(row: 1, section: 1),
IndexPath(row: 2, section: 1),
IndexPath(row: 2, section: 0)]
want to convert this to
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]