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:
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;
PHFetchResult * recentlyDeletedAlbum = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:1000000201 options:nil];
This returns collection of all recently deleted assets. You can iterate and get PHAsset for all objects in this collection to check if your PHAsset was deleted or not.
There is no property indicating if the phasset is deleted or not
the only way it worked for me is to check again with the PHAssetLocalID
if PHAsset.fetchAssets(withLocalIdentifiers: [pHAsset.localIdentifier], options: .none).count == 0 { }