以下 NSFetchRequest 不会将任何结果返回到数组中。我怀疑 NSPredicate 的语法有问题。有任何想法吗?
-(NSManagedObject*)requestTheSingleEntity:(NSString *)entityDescription ForWhichIntegerAttribute:(NSString *)attribute isEqualTo:(int)value
{
NSFetchRequest *request = [[NSFetchRequest alloc]init];
NSEntityDescription *e = [[model entitiesByName] objectForKey:entityDescription];
[request setEntity:e];
NSPredicate *p = [NSPredicate predicateWithFormat:@"(%@ == %@)", attribute, [NSNumber numberWithInt:value]];
[request setPredicate:p];
NSError *er;
NSArray *results = [context executeFetchRequest:request error:&er];
NSLog(@"the count of results = %d", [results count]);