A function in my app returns an image and I'm now trying to get the images creationDate
and location
.
How is this possible with/without using PHAsset?
According to Apple's documentation, you should be able to do that using:
let location = asset.location
let creationDate = asset.creationDate
They are properties of PHAsset class.
Take a look at: location and creationDate.
If you are using UIImagePickerControllerDelegate
and it will return the phAsset
in the info dictionary. Once you get the dictionary all the properties of phAsset
will be available.
class ViewController: UIViewController, UIImagePickerControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let asset = info[.phAsset] as? PHAsset
print(asset?.creationDate ?? "None")
print(asset?.location ?? "None")
dismiss(animated: true, completion:nil)
}