Skip to content

Instantly share code, notes, and snippets.

@monsoir
Created December 6, 2016 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monsoir/e9f573bfa430bc56ae6b9b2e2aff8e6e to your computer and use it in GitHub Desktop.
Save monsoir/e9f573bfa430bc56ae6b9b2e2aff8e6e to your computer and use it in GitHub Desktop.
// Save Image to Photos, compatible with asynchronous callback
+ (void)saveImageToPhoto:(UIImage *)image completionTarget:(id)completionTarget completionSelector:(SEL)completionSelector contextInfo:(void *)contextInfo{
if (completionTarget && [completionTarget respondsToSelector:completionSelector]) {
UIImageWriteToSavedPhotosAlbum(image, completionTarget, completionSelector, contextInfo);
} else {
#if DEBUG
NSLog(@"%s: completionTarget does not response to completionSelector.", __func__);
#endif
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment