UIImageWriteToSavedPhotosAlbum is not working reliably for me.
It seems to work about a third of the times I call it.
When I say does not work, I mean the callback is not called, and it silently returns
When I use the code snipped below I get the results:
Call UIImageWriteToSavedPhotosAlbum Called UIImageWriteToSavedPhotosAlbum
If I call it twice in a row sometimes the first call works, never the second.
Neither of the print statements in the callback are executed
class ImageSaver: NSObject { func writeToPhotoAlbum(image: UIImage) { print("Call UIImageWriteToSavedPhotosAlbum") UIImageWriteToSavedPhotosAlbum(image, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil) print("Called UIImageWriteToSavedPhotosAlbum") } // https://www.hackingwithswift.com/example-code/media/uiimagewritetosavedphotosalbum-how-to-write-to-the-ios-photo-album @objc func image(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) { if let error = error { // we got back an error! print("Error: \(error.localizedDescription)") } else { print ("Image saved") } } }