0

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.

M.Masa
  • 532
  • 4
  • 20

1 Answers1

0

+ creationRequestForAssetFromVideoAtFileURL: is for video. I think you should use + creationRequestForAssetFromImageAtFileURL: instead.

Lumialxk
  • 6,239
  • 6
  • 24
  • 47
  • as a usual you can check NSError code, userInfo properties collect error information and prepare readable message for users. – Ali Kıran Jul 10 '16 at 09:18
  • 1
    @AliKıran Yes I know about the userInfo in NSError. I'd like to know the **corresponding** error info to ALAssetsLibraryWriteDiskSpaceError and ALAssetsLibraryWriteBusyError. If possible I implement retry code internally. – M.Masa Jul 10 '16 at 11:35