[英]Swift 3.0: Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'
接收Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'
在enumerateIndexesUsingBlock中Value of type 'IndexSet' has no member '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
}
}
Foundation类型NSIndexSet
具有enumerateIndexesUsingBlock
方法。 Swift 3中相应的覆盖类型IndexSet
是一个集合,因此您只需将每个索引映射到IndexPath
:
extension IndexSet {
func bs_indexPathsForSection(_ section: Int) -> [IndexPath] {
return self.map { IndexPath(item: $0, section: section) }
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.