0

我在使用 NSPredicate 过滤匹配图像名称来获取图像时遇到问题。

代码在PHFetchReult *fetchResult.

错误信息是:

2016-09-15 00:51:25.112 PICTAG[1122:971448] -[__NSCFString objectID]: unrecognized selector sent to instance 0x14d89150
2016-09-15 00:51:25.114 PICTAG[1122:971448] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectID]: unrecognized selector sent to instance 0x14d89150'

我的代码是:

-(NSMutableArray *) getAllMatchingPhotos {
    NSMutableArray *matchingPhotos = [[NSMutableArray alloc]init];

    while(matchingPhotos.count != photos.count){
        int i = 0;
        PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
        fetchOptions.predicate = [NSPredicate predicateWithFormat:@"SELF == %@",[photos[i] valueForKey:@"keyFilePath"]];
        PHFetchResult *fetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:fetchOptions];
        [matchingPhotos addObject:fetchResult];
        i++;
    }

    for (int j = 0; j < matchingPhotos.count; j++){


        PHImageRequestOptions *requestOptions = [[PHImageRequestOptions alloc] init];
        requestOptions.resizeMode   = PHImageRequestOptionsResizeModeFast;
        requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeFastFormat;
        requestOptions.synchronous = true;

        PHImageManager *manager = [PHImageManager defaultManager];
        [manager requestImageForAsset:matchingPhotos[j] targetSize:CGSizeMake(100, 100) contentMode:PHImageContentModeDefault options:requestOptions  resultHandler:^void(UIImage *image, NSDictionary *info) {
            @autoreleasepool {

                [finalArray addObject:image];

            }
        }];
    }
    return finalArray;
}
4

0 回答 0