I was trying to save an image to the user camera roll on my iPhone using this code:
UIImageWriteToSavedPhotosAlbum(uiImage, nil, nil, nil)
But despite not crashing or giving an error, it was failing. I made sure the image was a valid (not nil) UIImage, and it was. So then I tried implementing the completion handler like so:
UIImageWriteToSavedPhotosAlbum(uiImage, self, #selector(self.image(_:didFinishSavingWithError:contextInfo:)), nil)
// ....
@objc func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if error != nil {
print("ERROR! ", error!.localizedDescription)
}
}
But this still didn't give me an error. Finally, I tried running on the simulator. This then gave me the following errors:
Connection to assetsd was interrupted or assetsd died
Error! Write failed
What is causing this to fail?