7

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?

pjmanning
  • 1,241
  • 1
  • 20
  • 48

2 Answers2

3

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.

Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
1

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)
    }