无法将类型为"Int"的值转换为预期的参数类型"索引路径"


if !isEditing {
collectionView.indexPathsForSelectedItems?.compactMap({ $0 }).forEach {_ in
collectionView.deselectItem(at: 0, animated: true)
// Cannot convert value of type 'Int' to expected argument type 'IndexPath'

只需使用forEach循环

collectionView.indexPathsForSelectedItems?.forEach({
collectionView.deselectItem(at:$0, animated: true)
})

最新更新