Fetching Assets using Asset resource failing with error "null"

461 views Asked by At

My application reads photos and videos available in Camera Roll, using PHAssetResource application is fetching the original photo and video data. Below is the code used to retrieve the data from Camera Roll.

for (PHAssetResource *resource in copyResources)
{
PHAssetResourceRequestOptions *options = [PHAssetResourceRequestOptions new];
options.networkAccessAllowed = allowCloud;
PHAssetResourceDataRequestID requestID = [[PHAssetResourceManager defaultManager] requestDataForAssetResource:resource options:options dataReceivedHandler:^(NSData *data) {} completionHandler:^(NSError *requestError) {}

}

Sometimes original asset fetch is getting failed,and completion handler gets called with error

Error Domain=NSCocoaErrorDomain Code=-1 "(null)"

I have no info why this is failing. Can you please provide some suggestions to overcome this issue.

1

There are 1 answers

0
holtmann On

Most likely this happens for photos/videos only in iCloud and not being on the device itself. The best approach would be to retry the request as the underlying issue is an iCloud server error.