I am running code UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
to save a photo(which is a image from a URL) to the album library. This works perfectly. However, This is a blind function and I would like to call a callback to know if it saved successfully.
Here is what I am trying.
UIImageWriteToSavedPhotosAlbum(image, self, #selector(imageSaved(_:didFinishSavingWithError:contextInfo:)), nil)
func imageSaved(image: UIImage!, didFinishSavingWithError error: NSError?, contextInfo: AnyObject?) {
if (error != nil) {
print("error")
print(error)
//Do Something with error associated with image
} else {
// Everything is alright.
}
}
I am trying to work with this code here and I keep getting Use of unresolved identifier imageSaved(_:didFinishSavingWithError:contextInfo:)
My problem is I don't understand the completion selector, and what is going on from Apple Documentation
- (void)image:(UIImage *)image
didFinishSavingWithError:(NSError *)error
contextInfo:(void *)contextInfo;
What does that ^ mean? How do I work with that?