I'm getting a strange error when trying to fetch images form iCloud, is there anything I'm doing wrong or it's an apple bug ?
The funny thing is that works from 2-3 try, I have no idea why
let options = PHImageRequestOptions()
options.deliveryMode = PHImageRequestOptionsDeliveryMode.highQualityFormat
options.isSynchronous = false
options.isNetworkAccessAllowed = true
options.progressHandler = { (progress, error, stop, info) in
if let error = error {
print(error.localizedDescription)
}
DispatchQueue.main.async {
let numFormatter = NumberFormatter()
numFormatter.maximumFractionDigits = 0
if let progressString = numFormatter.string(from: NSNumber(value: progress * 100)) {
print("Downloading from iCloud \(progressString) %")
if progress >= 0.99 {
self.hideLoadingLabel()
}
}
}
print("progress: \(progress)")
}
PHImageManager.default().requestImage(for: self.selectedAsset, targetSize: CGSize(width: 300, height: 300), contentMode: .aspectFill, options: options) {
image, info in
self.hideLoadingLabel()
guard let image = image else { return }
let vc = RSKImageCropViewController(image: image, cropMode: RSKImageCropMode.circle)
vc.delegate = self
DispatchQueue.main.async {
self.navigationController?.pushViewController(vc, animated: true)
}
}
}
This is a bug in iCloud. Sign out of iCloud and reboot and sign back in and it will be fixed. It has been a bug for many years.