Search code examples
iosphotosinfo

get geotag info for photos using PHImageManager


I'm trying to list geo tag info (longitude and latitude) for all photos, obtained using

PHImageManager.defaultManager().requestImageForAsset(fetchResult.objectAtIndex(1) as! PHAsset, targetSize: CGSize(width: 100.0, height: 100.0), contentMode: PHImageContentMode.AspectFill, options: options) { (image, info)

however, info doesn't seem to contain this information, is there any way to get this information using Photos framework?

thank you, Anton


Solution

  • PHAsset itself hold the CLLocation (i.e geo location) for the image. There is no need to request image data for it.

    All you need to do is

    fetchResult.objectAtIndex(1).location 
    

    Here is the link to the documentation page for PHAsset https://developer.apple.com/reference/photos/phasset