I would like to get a fixed batch of images located on an iOS device. I am using the new Photos Framework and I already found this workaround:
PHFetchOptions *allPhotosOptions = [PHFetchOptions new];
allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
PHFetchResult *allPhotosResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:allPhotosOptions];
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(currentIndex, batch_size)];
[allPhotosResult enumerateObjectsAtIndexes:indexSet options:0 usingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop)
{
}
It works fine, but I first extract all the photos using fetchAssetsWithMediaType, and then select a subset of the result to load the application, which seems pretty heavy ...
I wanted to know if there is a way to directly load a batch of photos in batch mode, rather than retrieve all of them and then repeat. Also, it would be ideal if I could store the indices of the last loaded batch to find out where I would get the next batch.
Thank you for your help!