I want to fetch PHAsset using assetURL. I used the following code :
NSURL *assetURL=[NSURL URLWithString:file.filePath];
PHFetchResult *fetchResult=[PHAsset fetchAssetsWithALAssetURLs:@[assetURL] options:nil];
PHAsset *asset= [fetchResult firstObject];
file.filePath has the asset url Im getting from
[[PHImageManager defaultManager]
requestImageDataForAsset:asset
options:imageRequestOptions
resultHandler:^(NSData *imageData, NSString *dataUTI,
UIImageOrientation orientation,
NSDictionary *info)
{[uploadingFile setValue:[NSString stringWithFormat:@"%@",[info valueForKey:@"PHImageFileURLKey"]] forKey:@"filePath"];}
But Im always getting the value of fetchResult
as nil
. Can someone tell me where Im going wrong ?
Is it because Im passing the wrong URL type?