How do I know if PHASsetCollection is a recently deleted collection?

There is a subtype of the recently added collection: PHAssetCollectionSubtypeSmartAlbumRecentlyAdded . However, there is no assetCollectionSubtype that identifies the Recently Deleted collection.

This is the description of the Recently Deleted collection in my case: (iOS 8.1.3): DF876BFD-...-C97F4628467C/L0/040 Recently Deleted assetCollectionType=2/1000000201

This indicates the type PHAssetCollectionTypeSmartAlbum . But what is the subtype of 1000000201 ?

201 must comply with PHAssetCollectionSubtypeSmartAlbumPanoramas according to the docs.

Can you trust the magic number 1000000201 so that it never changes? Probably not.

However, you can get a recently deleted collection:

 PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:1000000201 options:nil]; 

There is a big difference in this particular smart album: PHAsset cannot be deleted (again) because it is garbage. Therefore, it would be important to know if the user should offer a deletion option.

Does anyone have any ideas?

+2
source share
1 answer

Regarding the selection of the recently deleted collection, a workaround.

 PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil]; __block PHAssetCollection *recentlyDeletedCollection; [smartAlbums enumerateObjectsUsingBlock:^(PHAssetCollection *smartAlbum, NSUInteger idx, BOOL *stop) { if ([smartAlbum.localizedTitle isEqualToString:@"Recently Deleted"]) { NSLog(@"Recently Deleted album is at %ld", idx); recentlyDeletedCollection = smartAlbums[idx]; } }]; 
0
source

Source: https://habr.com/ru/post/978199/


All Articles