My code uses ALAssetsLibrary to get/save images on iPhone so far. And Currently I'm changing over from ALAssetsLibrary to PHPhotoLibrary.
In the migration I looked for error codes such as, ALAssetsLibraryWriteBusyError and ALAssetsLibraryWriteDiskSpaceError, but I couldn't. When my application cannot save images. I want to let users know the reason by showing error dialog.
My code for saving images is like below,
- (void)savePhotoFile:(NSURL *)fileURL completion:(savePhotoFileCompletion)completion
{
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest;
assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:fileURL];
if (self.assetCollection) {
PHAssetCollectionChangeRequest *assetCollectionChangeRequest =
[PHAssetCollectionChangeRequest changeRequestForAssetCollection:self.assetCollection];
[assetCollectionChangeRequest addAssets:@[ [assetChangeRequest placeholderForCreatedAsset] ]];
}
}
completionHandler:^(BOOL success, NSError *_Nullable error) {
DBGLog(@"success=%@, error=%@", (success ? @"YES" : @"NO"), error);
completion(success, error);
}];
}
Does anyone know the corresponding error codes in PHPhotoLibrary ? I'd really appreciate any information about this issue.