You can do it sneakily† using the undocumented PHAsset.ALAssetURL
property, but I\'m looking for something documented.
† In Objective-C, this will
I wanted to be able to get a URL for an asset too. However, I have realised that the localIdentifier
can be persisted instead and used to recover the PHAsset
.
PHAsset* asset = [PHAsset fetchAssetsWithLocalIdentifiers:@[localIdentifier] options:nil].firstObject;
Legacy asset URLs can be converted using:
PHAsset* legacyAsset = [PHAsset fetchAssetsWithALAssetUrls:@[assetUrl] options:nil].firstObject;
NSString* convertedIdentifier = legacyAsset.localIdentifier;
(before that method gets obsoleted...)
(Thanks holtmann - localIdentifier
is hidden away in PHObject
.)