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

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

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]; } }]; 

然而,这会在block内的第一行不断中断,并出现以下错误: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported predicate in fetch options: mediaType == 2'

我做了一点研究,发现了这个链接 。
我想知道这是一个Apple bug还是我的代码有问题。
它似乎对那些提到这个答案的人有用,这很奇怪,因为它基本上是一样的。

提前致谢,
阿尼什

编辑:
我想我在Apple的文档中找到了答案。 看起来mediaType只是PHAsset的关键,而不是PHAssetCollection 。 所以现在我想问题是如何只用video或图像来获取PFAssetCollection