Working on an app that is iOS 8, and handles a lot of photos, I need to uniquely identify PHassets but cannot find any property to use? I found one property on
PHObject/localIdentifier
documented here
https://developer.apple.com/library/ios/documentation/Photos/Reference/PHObject_Class/index.html#//apple_ref/occ/instp/PHObject/localIdentifier
Is there any way to have a unique ID on PHAsset? PHObject is a bit heavier to use.
Yes, that's the only property to use.
However, PHObject
implements both -hash
and -isEqual:
methods. It also conforms to NSCopying
protocol, which means that it can be used as a key in dictionaries and can be put in sets, etc. It also continues to work when you reload PHAsset
objects. This is a huge win over ALAsset
class. The implementation of -isEqual
is much faster than the localIdentifier
property and can be safely used on the main thread. You could use profiler to get an idea of what's under the hood.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With