小编Ani*_*mar的帖子

错误:'获取选项中不支持的谓词:mediaType == 2'

我正在尝试使用smartAlbum生成一个仅包含视频或仅包含照片或两者的数组.
你可以在下面看到我的代码:

    PHFetchResult *collectionList = [PHCollectionList fetchMomentListsWithSubtype:PHCollectionListSubtypeMomentListCluster options:nil];
    PHFetchOptions *options = nil;
        if (self.xSelected) {
            options = [[PHFetchOptions alloc] init];
            options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
            options.predicate = [NSPredicate predicateWithFormat:@"mediaType = %d",PHAssetMediaTypeImage];
        }
        if (self.ySelected) {
            options = [[PHFetchOptions alloc] init];
            options.predicate = [NSPredicate predicateWithFormat:@"mediaType = %d",PHAssetMediaTypeVideo];
        }

    [collectionList enumerateObjectsUsingBlock:^(PHCollectionList *collection, NSUInteger idx, BOOL *stop) {
        PHFetchResult *momentsInCollection = [PHAssetCollection fetchMomentsInMomentList:collection options:options];
        for (id moment in momentsInCollection) {
            PHAssetCollection *castedMoment = (PHAssetCollection *)moment;
            [_smartAlbums insertObject:castedMoment atIndex:0];
        }
    }];
Run Code Online (Sandbox Code Playgroud)


然而,这在内部的第一行不断打破block并给出以下错误: …

iphone nspredicate ios photosframework

15
推荐指数
1
解决办法
1711
查看次数

标签 统计

ios ×1

iphone ×1

nspredicate ×1

photosframework ×1