【发布时间】:2019-04-27 04:26:35
【问题描述】:
最近想根据indexPaths删除单元格,所以函数的输入参数是[IndexPath]类型,我需要根据indexPath.section将[IndexPath]拆分成几个数组,有没有简单的方法做这个?
例如
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]
【问题讨论】:
-
请不要忘记通过单击最能解决您的问题的答案左侧的复选标记来表明您的问题已成功回答。在你来这里的所有这些年里,你没有对任何问题这样做过。您应该回顾所有问题,并在适当的情况下检查答案是否最能解决该问题。