Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法转换类型为';Int';到预期的参数类型';indexath';_Ios_Swift - Fatal编程技术网

Ios 无法转换类型为';Int';到预期的参数类型';indexath';

Ios 无法转换类型为';Int';到预期的参数类型';indexath';,ios,swift,Ios,Swift,只需使用forEach循环即可 if !isEditing { collectionView.indexPathsForSelectedItems?.compactMap({ $0 }).forEach {_ in collectionView.deselectItem(at: 0, animated: true) // Cannot convert value of type 'Int' to expected argument type 'IndexP

只需使用
forEach
循环即可

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'

对于
at:0
您是指
at:$0
?是@matt For at:0您是指at:$0吗?
collectionView.indexPathsForSelectedItems?.forEach({
    collectionView.deselectItem(at:$0, animated: true)
})