Hello everyone.
I have a controller in which I just fetch images in user's gallery and show them. It used to work with XCode 7.3, but after upgrading it to XCode 8.0 and updating the code for Swift 3.0 compatibility, it gives me a strange and very generic error:
Creating an image format with an unknown type is an error
I am not able to figure out what is not working here. My code is the following:
let imgManager = PHImageManager.default()
let requestOptions = PHImageRequestOptions()
requestOptions.isSynchronous = false
requestOptions.deliveryMode = PHImageRequestOptionsDeliveryMode.fastFormat
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key:"creationDate", ascending: false)]
let fetchResult = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: fetchOptions)
if fetchResult.count > 0 {
for i in 0...(fetchResult.count-1) {
imgManager.requestImage(for: fetchResult.object(at: i), targetSize: view.frame.size, contentMode: PHImageContentMode.aspectFit, options: requestOptions, resultHandler: { (image, _) in
//do some stuff
self.progressView.isHidden = true
})
}
} else {
self.progressView.isHidden = true
}
In this code I removed the image visualization code for readability. The instruction that triggers the error is the one in line 14. Any help will be very appreciated.