ALAssetsLibraryGroupsEnumerationResultsBlock in swift 3

117 views Asked by At

Since I "upgraded" my project to Swift 3, I get an exception when trying to use the ALAssetLibrary. I use this instead of Photos library because I want to write extensive metadata to the photo file and I have not found a way to do this with the Photos library so far.

The following code now fails:

let usingBlock = {
    (group: ALAssetsGroup?, stop: UnsafeMutablePointer<ObjCBool>) in
    // Code to execute
} as! ALAssetsLibraryGroupsEnumerationResultsBlock

It seems that the cast fails. I need an object of type ALAssetsLibraryGroupsEnumerationResultsBlock in order to call ALAssetsLibrary.enumerateGroupsWithTypes.

Again I know this is deprecated, but it should still work somehow shouldn't it?

1

There are 1 answers

0
zjames On

The signature of ALAssetsLibraryGroupsEnumerationResultsBlock has changed to typealias ALAssetsLibraryGroupsEnumerationResultsBlock = (ALAssetsGroup?, UnsafeMutablePointer<ObjCBool>?) -> Void

You need to make the stop argument an optional and then it should work (see apple docs