2016-09-22 3 views
2

수신 Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'에서 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

어떤 경우에 대한-에서 대신 블록의 사용? self.enumerated()의 (인덱스, 값)에 대한 >>> { print ("인덱스 = \ (인덱스), 값 = \ (값)") } – Che

답변

2

기초 유형 NSIndexSetenumerateIndexesUsingBlock 방법이있다. 스위프트 3에서 해당 오버레이 유형 IndexSet는 모음입니다 때문에 당신이 할 수있는 단지 지도IndexPath 각 지수 :

extension IndexSet { 
    func bs_indexPathsForSection(_ section: Int) -> [IndexPath] { 
     return self.map { IndexPath(item: $0, section: section) } 
    } 
} 
관련 문제