How do I determine if a PHAsset in a PHFetchResult represents a deleted photo?

前端 未结 3 1124
长情又很酷
长情又很酷 2020-12-29 11:14

I\'m trying to grab a thumbnail of the last photo taken on a device using the new Photos framework in iOS 8. The code I have right now to do this is the following:



        
3条回答
  •  感情败类
    2020-12-29 11:59

    PHFetchResult *fetchResults = [PHAsset fetchAssetsWithOptions:options];
    NSArray* tempArray = [fetchResults objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, fetchResults.count)]];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"description contains %@",@"assetSource=3"];
    NSArray *filteredArray =  [tempArray filteredArrayUsingPredicate:predicate];
    

    The filteredArray doesn't include the "Recently Deleted" album and doesn't have identical looking photos. Also for the deleted photo asset in your assetsInfo, the following two will return NO.

    [asset canPerformEditOperation:PHAssetEditOperationContent] 
    [asset canPerformEditOperation:PHAssetEditOperationProperties]
    

    In PHAsset Runtime Headers there are useful properties:

    @property (getter=isTrashed, nonatomic, readonly) bool trashed;
    @property (nonatomic, readonly) NSDate *trashedDate;
    

提交回复
热议问题