How to I extract a PHAsset's Location property?

痞子三分冷 提交于 2020-01-06 14:09:44

问题


Xcode says that PHAsset doesn't have the 'location' member.

What's the remedy for Swift?


回答1:


Short answer: you might have forgotten to import CoreLocation;

import Photos
import CoreLocation

let asset: AnyObject? = nil

if let asset = asset as? PHAsset {
    let location = asset.location
}

When I remove the CoreLocation import, I can replicate your error.



来源:https://stackoverflow.com/questions/30249163/how-to-i-extract-a-phassets-location-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!