iosobjective-calassetslibraryalasset

Get UID URL for ALAsset with ALAssetPropertyAssetURL


I get asset URL by calling [asset valueForProperty:ALAssetPropertyAssetURL] sometimes it returns nil or may be asset is nil (I've seen it in the crash logs). I've read in the documentation:

ALAssetPropertyAssetURL
The key to retrieve a URL identifier for the asset.

The corresponding value is an NSURL object.

This URL is used by the library-change notifications to identify assets and asset groups. Only the ALAssetRepresentation and ALAssetsGroup classes support this property.

I think it is mean, that I can't get ALAssetPropertyAssetURL property from ALAsset, but it works any time when I run it.

Questions:

  1. How I can get Asset url to use it in [PHAsset fetchAssetsWithALAssetURLs: ....]?

UPD

I don't understand this: "How to get URL if only the ALAssetRepresentation and ALAssetsGroup classes support this property?"


Solution

  • We could use something like this with ALAsset object

    [[asset defaultRepresentation] url]