PHAsset get original file name

╄→尐↘猪︶ㄣ 提交于 2019-12-02 18:19:23

On iOS 8 your solution is the right (and only approach) to get a filename at all.

On iOS 9 this works:

NSArray *resources = [PHAssetResource assetResourcesForAsset:asset];
NSString *orgFilename = ((PHAssetResource*)resources[0]).originalFilename;

Short way to get file name with one line of code. Asset have a property for accessing file name.

 NSString*FileName=[asset valueForKey:@"filename"];
 NSLog(@"File name %@",FileName);

Its done.

Note: Accepted answer takes lots of time to load a phasset but it works.

Maybe you can use the method, it works above iOS8:

 [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {

    CIImage *fullImage = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL];
    NSLog(@"%@",contentEditingInput.fullSizeImageURL);//get url
    NSLog(@"%@", fullImage.properties.description);//get {TIFF}, {Exif}
}];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!