How to find identifier of a photo asset in IOS

◇◆丶佛笑我妖孽 提交于 2019-12-12 18:27:19

问题


I am writing an app which saves a photo stored in a custom album and associates other information with it in an object. The object is then saved in core data. I would like to store a reference to the photo in the object. Is there a unique identifier that is available or can be derived. I need to be able to access the photo. I am using Photos framework.


回答1:


Keep in mind that localIdentifier's may change when iOS is updated, and in this case whatever value you had saved locally will become useless.

Check this other question for further information.




回答2:


Every thing from Photos framework is PHObject and the PHObject class implements the isEqual: and hash methods in terms of its localIdentifier property, you can use techniques that depend on these methods to keep track of photo entities.

var localIdentifier: String { get }

A unique string that persistently identifies the object



来源:https://stackoverflow.com/questions/34237013/how-to-find-identifier-of-a-photo-asset-in-ios

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