下面的代码在调用fetchAssetsWithOptions时抛出一个NSInvalidArgumentException:
PHFetchOptions *allPhotosOptions = [[PHFetchOptions alloc] init];
allPhotosOptions.sortDescriptors =
@[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
allPhotosOptions.predicate =
[NSPredicate predicateWithFormat:@"pixelHeight >= pixelWidth * 1.95" ];
self.allPhotos = [PHAsset fetchAssetsWithOptions:allPhotosOptions];这条信息是
NSInvalidArgumentException ... reason: '*** -constantValue only defined for abstract class.
Define -[NSFunctionExpression constantValue]!'我尝试了许多谓词格式字符串的变体,但在尝试使用乘法时总是得到此消息。我做错了什么?
发布于 2015-12-14 12:15:29
我不确定为什么,但是当你没有传递任何格式参数给predicateWithFormat:并将其用于照片时,你会得到这个错误;
我能够通过确保传递的是格式参数来解决这个问题。所以在你的例子中:
float heightLimit = pixelWidth * 1.95;
[NSPredicate predicateWithFormat:@"pixelHeight >= %f", heightLimit];https://stackoverflow.com/questions/33769372
复制相似问题