gpt4 book ai didi

ios - swift 3.0 : Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'

转载 作者:搜寻专家 更新时间:2023-10-31 22:30:19 24 4
gpt4 key购买 nike

接收 “IndexSet”类型的值在 enumerateIndexesUsingBlock 处没有成员“enumerateIndexesUsingBlock” 错误。

/**
Extension for creating index paths from an index set
*/
extension IndexSet {
/**
- parameter section: The section for the created NSIndexPaths
- return: An array with NSIndexPaths
*/
func bs_indexPathsForSection(_ section: Int) -> [IndexPath] {
var indexPaths: [IndexPath] = []

self.enumerateIndexesUsingBlock { (index:Int, _) in
indexPaths.append(IndexPath(item: index, section: section));
}

return indexPaths
}
}

最佳答案

基础类型 NSIndexSet 有一个 enumerateIndexesUsingBlock方法。来自 Swift 3 的相应覆盖类型 IndexSet 是一个集合,因此您可以映射IndexPath 的索引:

extension IndexSet {
func bs_indexPathsForSection(_ section: Int) -> [IndexPath] {
return self.map { IndexPath(item: $0, section: section) }
}
}

关于ios - swift 3.0 : Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39638538/

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