Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHFetchOptions mediaSubtype predicate

Following predicate should fetch all the screenshots only, which work just fine.

options.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype & %d) != 0", PHAssetMediaSubtypePhotoScreenshot];

However if I try to exclude screenshots only by using follwing predicate, all of the images are excluded

options.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype & %d) = 0", PHAssetMediaSubtypePhotoScreenshot];    

All Im trying to do is to exlude screeshots from asset fetch.

Is this known bug or am I missing something ?

like image 319
stringCode Avatar asked Feb 05 '16 16:02

stringCode


1 Answers

I made a quick check and this seems to work for me:

 PHFetchOptions *options = [[PHFetchOptions alloc] init];
 options.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype & %d) == 0", PHAssetMediaSubtypePhotoScreenshot];

Note the double equal in the predicate to do the comparison instead of the single one.

like image 76
Pablo Carrillo Alvarez Avatar answered Oct 17 '22 08:10

Pablo Carrillo Alvarez