2016-09-22 6 views
2

enumerateIndexesUsingBlockでValue of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'のエラーが発生しました。Swift 3.0: 'IndexSet'型の値に '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 
    } 
} 
+0

代わりにブロックの何のための-で使用する場合は? >>> for(index、value)for self.enumerated() { print( "index = \(index)、value = \(value)") } – Che

答えて

2

財団タイプNSIndexSetenumerateIndexesUsingBlock 方法を有しています。スウィフト3から対応するオーバーレイタイプIndexSetは、コレクションで、IndexPathのため、次のことができますだけでマップ各 インデックス:

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