[英]Swift 3.0: Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'
Receiving Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'
error at 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
}
}
The Foundation type NSIndexSet
has a enumerateIndexesUsingBlock
method. Foundation类型
NSIndexSet
具有enumerateIndexesUsingBlock
方法。 The corresponding overlay type IndexSet
from Swift 3 is a collection, therefore you can just map each index to an IndexPath
: 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.