Get Filename From PHAsset swift 5 IOS13

Viewed 145

My Question is how we get file Name From PHAsset Which Are Picked By gallery

var allSmallPic: [PHAsset] = []

PHImageManager.default().requestImage(for: allSmallPic[indexPath.row], targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: nil) { (image, info) in
        
        
        
        cell.ImageVieww.image = image
        cell.Labell.text = "\(String(describing: info!))"
        print(info!)

                            }
2 Answers
    let resource1 = PHAssetResource.assetResources(for:self.allSmallPic[indexPath.row])
    print("Get resources\(resource1)")
    cell.Labell.text = resource1[0].originalFilename

As you Know PHAsset is representation of an image, video, or Live Photo in the Photos library.

So I want to show the file names into my tableViewCell Like this enter image description here

when no results found i'm start read documentations and i found PHAssetResource and they help me to Get image name

let resource1 = PHAssetResource.assetResources(for:self.allSmallPic[indexPath.row])
    print("Get resources\(resource1)")
    cell.Labell.text = resource1[0].originalFilename

The allSmallPic is global array which store PHAsset

Related