Not providing an array of NSSortDescriptors to a PHFetchOptions object results in crash

Originator:don.holly
Number:rdar://19023620 Date Originated:11/18/2015
Status:Open Resolved:
Product:iOS Product Version:8.1.1
Classification:Crash Reproducible:Always
 
Summary:
8.1.1 seems to have introduced a regression to PhotoKit which will cause [PHAsset fetchAssetsInAssetCollection] to crash if options.sortDescriptors is not set on the PHFetchOptions

Steps to Reproduce:
Fetch the assets from an assetCollection using PHFetchOptions that contains no sortDescriptors (example project included)

PHFetchOptions *options = [PHFetchOptions new];
options.includeAllBurstAssets = YES;
options.includeHiddenAssets = YES;

NSMutableArray *allAssets = @[].mutableCopy;

PHFetchResult *momentsResult = [PHAssetCollection fetchMomentsWithOptions:options];
[momentsResult enumerateObjectsUsingBlock:^(PHAssetCollection *moment, NSUInteger idx, BOOL *stop) {
    
    PHFetchResult *assetsResult = [PHAsset fetchAssetsInAssetCollection:moment options:options];
    
    [assetsResult enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) {
        if (asset) {
            [allAssets addObject:asset];
        }
    }];
}];


Expected Results:
Don't crash

Actual Results:
Crash

Version:
iOS 8.1.1

Notes:


Configuration:
Any device or simulator running iOS 8.1.1

Attachments:
'PHFetchOptionsCrash.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!