Syed Tariq
Syed Tariq

Reputation: 2928

How to find identifier of a photo asset in IOS

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.

Upvotes: 4

Views: 4090

Answers (2)

otaviokz
otaviokz

Reputation: 382

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.

Upvotes: 2

guhan0
guhan0

Reputation: 676

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

Upvotes: 0

Related Questions