问题
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