How to get the selected image name from the photo library using PHPicker. is it possible? or I want alternate solution
How to get selected image name
Add a Comment
How to get the selected image name from the photo library using PHPicker. is it possible? or I want alternate solution
Get the PHAssets. From there, you can extract metadata and find what you need:
https://stackoverflow.com/questions/44977292/how-to-retrieve-phasset-from-uiimagepickercontroller
Get the PHAssets. From there, you can extract metadata and find what you need:
https://stackoverflow.com/questions/44977292/how-to-retrieve-phasset-from-uiimagepickercontroller
To be more precise, you could try this:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
// info: Local variable inserted by Swift 4.2 migrator.
let info = convertFromUIImagePickerControllerInfoKeyDictionary(info)
if let url = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.imageURL)] as? URL {
let fileName = url.lastPathComponent
}
}
// Helper function inserted by Swift 4.2 migrator. For imagePickerController
fileprivate func convertFromUIImagePickerControllerInfoKeyDictionary(_ input: [UIImagePickerController.InfoKey: Any]) -> [String: Any] {
return Dictionary(uniqueKeysWithValues: input.map {key, value in (key.rawValue, value)})
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromUIImagePickerControllerInfoKey(_ input: UIImagePickerController.InfoKey) -> String {
return input.rawValue
}
Is it the name you are looking for ?