Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fetching photos by date - iOS

Disclaimer –I’m new to iOS and to this forum too. I have a need to get pictures taken in specific dates (let’s say January 9-January 12) . I don't want to go over all the photos in the photo library for enhance the app performance. I am looking for some public API to full fill my requirement. Does apple Photo Framework supports fetching photo collection by date? Is PHFetchOptions the solution and if so what is the right way to use it ?

like image 611
Amit Fisher Avatar asked Jan 08 '23 16:01

Amit Fisher


1 Answers

You can create a predicate to specify the dates:

PHFetchOptions *fetchOptions = [PHFetchOptions new];

fetchOptions.predicate = [NSPredicate predicateWithFormat:@"creationDate > %@ AND creationDate < %@", startDate, endDate];

PHFetchResult *fetchResult = [PHAsset fetchAssetsWithOptions:fetchOptions];
like image 72
Wain Avatar answered Jan 14 '23 13:01

Wain