Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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 查找2个NSIndexPath数组的交集_Ios_Arrays_Swift_Swift2_Nsindexpath - Fatal编程技术网

Ios 查找2个NSIndexPath数组的交集

Ios 查找2个NSIndexPath数组的交集,ios,arrays,swift,swift2,nsindexpath,Ios,Arrays,Swift,Swift2,Nsindexpath,我试图找到哪些nsindexpath是同时可见和选中的。这两个阵列的初始化方式如下: 让visibleSelectedItems=collectionView.indexPathsForVisibleItems() 让selectedItems=collectionView.indexPathsForSelectedItems() 我基本上是在寻找两个数组的交集。索引路径声明为nsindepath(forItem:Int,instation:Int),与您所说的完全一样-使用交叉点。通过将两个数

我试图找到哪些nsindexpath是同时可见和选中的。这两个阵列的初始化方式如下:

让visibleSelectedItems=collectionView.indexPathsForVisibleItems()

让selectedItems=collectionView.indexPathsForSelectedItems()


我基本上是在寻找两个数组的交集。索引路径声明为
nsindepath(forItem:Int,instation:Int)

,与您所说的完全一样-使用交叉点。通过将两个数组强制为集合,可以轻松地完成此操作。集合具有交集方法。然后,如果需要,可以强制返回到数组