gpt4 book ai didi

arrays - 如何快速从数组中查找行

转载 作者:行者123 更新时间:2023-11-30 13:31:54 25 4
gpt4 key购买 nike

您好,我遇到了有关 collectionView 项目的问题。

  var selectedPartecipants = [NSDate]() // this is the array [Item[0], Item[1] etc... ]

func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) {



if let deselectedData:NSDate = partecipantsAtEvent[indexPath.row].date! {


if let index = selectedPartecipants.indexOf(deselectedData) {

selectedPartecipants.removeAtIndex(index)
("item[0] cancelled - I have to search the item in collection view that now is new item[0] in the array")


}

}


}

当我在 collectionView 中取消选择 item[0] 时,代码取消数组中的 item[0] 并希望在 collectionView 中查找新项目,现在是数组中的新 item[0]。有任何想法吗?

最佳答案

听起来您想迭代 Collection View 中的所有项目。因此,要找到您感兴趣的项目,请循环访问partecipantsAtEvent数组并查找日期与selectedParticpants[0]匹配的项目。

关于arrays - 如何快速从数组中查找行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36484618/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com