使用ALAssetPropertyAssetURL获取ALAsset的UID URL

问题描述 投票:0回答:1

我通过调用[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属性,但是当我运行它时它可以随时工作。

问题:

  1. 如何在[PHAsset fetchAssetsWithALAssetURLs:....]中获取Asset url?

UPD

我不明白这一点:“如果只有ALAssetRepresentation和ALAssetsGroup类支持这个属性,如何获取URL?”

ios objective-c alassetslibrary alasset
1个回答
0
投票

我们可以使用ALAsset对象这样的东西

[[asset defaultRepresentation] url]
© www.soinside.com 2019 - 2024. All rights reserved.