作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
接收 “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/
在我的单元测试中,我查看了一些边界条件,但我的测试一直失败。当它的索引一直延伸到 NSNotFound-1(每个文档的最大合法值)时,我追踪到它通过索引集进行枚举。 使用这个测试代码: // Crea
我正在编写一种将数据从 TableView 复制到粘贴板的方法,但是如果选择了任何行,它应该专门只复制所选行中的数据,因此我需要遍历索引集 ... func createExportText(from
接收 “IndexSet”类型的值在 enumerateIndexesUsingBlock 处没有成员“enumerateIndexesUsingBlock” 错误。 /** Extension fo
我是一名优秀的程序员,十分优秀!