2

In my app i want to display photo gallery with Album folders and i have a title for the album and how to get all photos from asset with specific title like Favourites,Recently Added,Camera roll ETC. Check my below code for fetching album title.

PHFetchOptions *allPhotosfetchOption = [[PHFetchOptions alloc]init];

    allPhotosfetchOption.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];

    allPhotosfetchOption.predicate = [NSPredicate predicateWithFormat:@"estimatedAssetCount > 0"];

    allPhotosfetchOption.predicate = [NSPredicate predicateWithFormat:@"mediaType == 1"];

    PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];

    [result enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop) {

        NSLog(@"album title %@", collection.localizedTitle);
    }];

OUTPUT :

2017-06-26 16:52:05.903 PhFolderNew[4712:147660] album title Panoramas
2017-06-26 16:52:05.904 PhFolderNew[4712:147660] album title Camera Roll
2017-06-26 16:52:05.906 PhFolderNew[4712:147660] album title Slo-mo
2017-06-26 16:52:05.907 PhFolderNew[4712:147660] album title Screenshots
2017-06-26 16:52:05.908 PhFolderNew[4712:147660] album title Bursts
2017-06-26 16:52:05.909 PhFolderNew[4712:147660] album title Videos
2017-06-26 16:52:05.910 PhFolderNew[4712:147660] album title Selfies
2017-06-26 16:52:05.912 PhFolderNew[4712:147660] album title Hidden
2017-06-26 16:52:05.913 PhFolderNew[4712:147660] album title Time-lapse
2017-06-26 16:52:05.916 PhFolderNew[4712:147660] album title Recently Added
2017-06-26 16:52:05.918 PhFolderNew[4712:147660] album title Depth Effect

Let me know how to pass Favourites into phasset and get all photos from Favourites?

Arun
  • 624
  • 4
  • 18
  • have a look https://stackoverflow.com/questions/25981374/ios-8-photos-framework-get-a-list-of-all-albums-with-ios8 or this https://stackoverflow.com/questions/32169185/how-to-fetch-all-images-from-custom-photo-album-swift – luckyShubhra Jun 26 '17 at 11:46
  • No its not the one, i can get the title and i am asking how you pass the title to the phasset to get all photos? – Arun Jun 26 '17 at 11:51

0 Answers0