Closed pronebird closed 9 years ago
Hi @pronebird , the errors are for different purposes, as the DOC said:
// This block is executed if the user does not grant access to the caller to access the data managed by the framework or if the data is currently unavailable. typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
// This block is executed when saving an image by -writeImageToSavedPhotosAlbum:completionBlock: finishes. The assetURL can later be used to reference the saved image. typedef void (^ALAssetsLibraryWriteImageCompletionBlock)(NSURL assetURL, NSError error);
Hope it helps :)
I got it, it's just weird that both handlers accept error, I'd expect one failure and one success block.
@pronebird u can wrap it with a success block instead of completion block. Just note that only invoke the success block when the error is nil in completion block.
[assetsLibrary saveImageData:imageData toAlbum:@"Album" metadata:metadata
completion:^(NSURL *assetURL, NSError *error) {
if (error) {
failure(error);
} else {
success(assetURL);
}
} failure:failure];
Why both completion and failure blocks take NSError parameters?