我通过调用[asset valueForProperty:ALAssetPropertyAssetURL]来获取资产URL,有时它返回nil或者资产是nil(我在崩溃日志中看到过它)。我在文档中读到:
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.
我认为这是卑鄙的,我无法从ALAsset获取ALAssetPropertyAssetURL属性,但是当我运行它时它可以随时工作。
问题:
UPD
我不明白这一点:“如果只有ALAssetRepresentation和ALAssetsGroup类支持这个属性,如何获取URL?”
我们可以使用ALAsset
对象这样的东西
[[asset defaultRepresentation] url]