0
以下NSFetchRequest不會返回任何結果到數組中。我懷疑NSPredicate的語法有問題。有任何想法嗎?帶NSPredicate的NSFetchRequest不返回任何結果
-(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]);
謝謝!我很感激。 – ChemDev 2013-05-12 04:14:57