Swift 3.0: Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'

前端 未结 1 1081
粉色の甜心
粉色の甜心 2021-01-20 00:25

Receiving Value of type \'IndexSet\' has no member \'enumerateIndexesUsingBlock\' error at enumerateIndexesUsingBlock.

/**
Extension for creatin         


        
1条回答
  •  失恋的感觉
    2021-01-20 00:55

    The Foundation type NSIndexSet has a enumerateIndexesUsingBlock method. The corresponding overlay type IndexSet from Swift 3 is a collection, therefore you can just map each index to an IndexPath:

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

    0 讨论(0)
提交回复
热议问题