5

There is a subtype for the recently added collection: PHAssetCollectionSubtypeSmartAlbumRecentlyAdded. However there is no assetCollectionSubtype that would identify 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 it is of type PHAssetCollectionTypeSmartAlbum. But what the heck is subtype 1000000201?

201 should be PHAssetCollectionSubtypeSmartAlbumPanoramas according to the docs.

Can the magic number 1000000201 be trusted to never change? Probably not.

However, this is how you can retrieve the recently deleted collection:

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

There is a major difference in this particular smart album: the PHAssets can not be deleted (again), because this is the trash. So it'd be essential to know if a delete option should be presented to the user.

Does anyone have an idea?

Clay Bridges
  • 11,602
  • 10
  • 68
  • 118
JensD
  • 253
  • 2
  • 9
  • 1
    did you find any other way apart from the localizedTitle to identify the deleted Albums – Ekra Mar 23 '16 at 12:40
  • Hi, does anyone know of a more up-to-date method for doing this? – Chris May 12 '20 at 12:07
  • 1
    As of end of 2021, this magic number `1000000201` still seems to be valid: ` 72053882-BF20-4D4A-B1A5-03D1DDAE1707/L0/040, title:"Recently Deleted", subtitle:"(null)" assetCollectionType=2/1000000201` – derpoliuk Nov 11 '21 at 19:01

1 Answers1

-1

Regarding picking out the "Recently Deleted" collection, here's 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];
    }
}];
Vincent Gigandet
  • 918
  • 10
  • 21