Check given PHAsset is iCloud asset?

后端 未结 6 1165
再見小時候
再見小時候 2021-02-02 14:16

I\'m trying to get PhAsset object. I want to segregate iCloud assets. Here is my code,

PHFetchResult *cloudAlbums = [PHAssetCollection fetchAssetCollectionsWithT         


        
6条回答
  •  隐瞒了意图╮
    2021-02-02 15:14

    It's a bit kind of hack, where I had to dig out the resource array and debug to find out my required information. But it works. Although this is an undocumented code and I'm not sure whether apple will reject the app because of this or not. Give it a try and see what happens!

    // asset is a PHAsset object for which you want to get the information    
    NSArray *resourceArray = [PHAssetResource assetResourcesForAsset:asset];
    BOOL bIsLocallayAvailable = [[resourceArray.firstObject valueForKey:@"locallyAvailable"] boolValue]; // If this returns NO, then the asset is in iCloud and not saved locally yet
    

    You can also get some other useful information from asset resource, such as - original filename, file size, file url, etc.

提交回复
热议问题