0

I have tried to use below API but get this error as below

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

- (PHAssetResourceDataRequestID)requestDataForAssetResource:(PHAssetResource *)resource
                                                options:(nullable PHAssetResourceRequestOptions *)options
                                    dataReceivedHandler:(void (^)(NSData *data))handler
                                      completionHandler:(void(^)(NSError *__nullable error))completionHandler;

Below is the sample implementation

    NSArray *assetResourcesArray = [PHAssetResource assetResourcesForAsset: myPhAssetObject];
    PHAssetResource *assetResource = [assetResourcesArray objectAtIndex:0];

[[PHAssetResourceManager defaultManager] requestDataForAssetResource:assetResource options:nil dataReceivedHandler:^(NSData * _Nonnull data) {
    //do something with video data
    NSLog(@"data %lu", [data length]);
}
                                                   completionHandler:^(NSError * _Nullable error) {
                                                       NSLog(@"error ======== %@", error);
                                                   }];

Any hint in the right direction would be highly appreciated.

Ekra
  • 3,241
  • 10
  • 41
  • 61
  • Sounds like a corrupt Photo-Library on the device. Do you maybe have a second device for testing? – holtmann Oct 18 '16 at 15:15
  • it is inconsistent in device sometimes it will work and sometimes it will not work. But in simulator it always works – Ekra Oct 19 '16 at 07:15

0 Answers0