繁体   English   中英

Swift 3.0:'IndexSet'类型的值没有成员'enumerateIndexesUsingBlock'

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM