0

我正在尝试创建谓词,但出现错误。我收到错误'NSInvalidArgumentException',原因:'无法解析格式字符串“title contains [cd] @%”'我试过这样:

request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]];
NSString *predicateString=[NSString stringWithFormat:@"title contains[cd] @% ",searchText];
request.predicate = [NSPredicate predicateWithFormat:predicateString];//error here

像这样

request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]];
request.predicate = [NSPredicate predicateWithFormat:@"title contains[cd] @%",searchText];//error here
4

1 回答 1

3

您的意思是%@, not @%,作为对象的格式说明符。

于 2012-05-03T11:56:36.530 回答