Understand how to retrieve the last photo from iOS devices from link below
How to retrieve the most recent photo from Camera Roll on iOS?
But I wanted to retrieve the last 20 photos or so on as I do not want to slow down the performance as well as let user to look at their photos in reverse order instead
I tried
long index = group.numberOfAssets - 2;
and Ended up with this error
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSIndexSet initWithIndexesInRange:]: Range {4294967294, 1} exceeds maximum index value of NSNotFound - 1'
Anyone can help here? thanks
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
***long index = group.numberOfAssets - 2;***
[group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:index]
options:0
usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop)