Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift 3, PHFetchResult.enumerateObjects error

Tags:

swift3

In swift 3,the method is show me "ambiguous use of 'enumerateObjects'",what happen.how can i do?

extension PHFetchResult {
public func assetCollection() -> [PHAssetCollection] {
    var list :[PHAssetCollection] = []
    self.enumerateObjects { (object, index, stop) in
        if object is PHAssetCollection {
            let collection = object as! PHAssetCollection
            list.append(collection)
        }
    }
    return list
}
}
like image 960
six Avatar asked Jun 20 '16 23:06

six


1 Answers

Swift 3.0: Just add the Round Brackets before Curly Brackets starts after enumerateObjects.

extension PHFetchResult {
  public func assetCollection() -> [PHAssetCollection] {
    var list :[PHAssetCollection] = []
    self.enumerateObjects ({ (object, index, stop) in
        if object is PHAssetCollection {
            let collection = object as! PHAssetCollection
            list.append(collection)
        }
    })
    return list
  }
}
like image 175
Kiran Jasvanee Avatar answered Oct 20 '22 20:10

Kiran Jasvanee