我這個消息崩潰未發現:核心數據:的keyPath名在實體
「NSInvalidArgumentException」的,理由是:「的keyPath名未找到實體
Obvisouly我不是我的查詢實體正確。
//fetching Data
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSManagedObjectContext *context = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Viewer" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSString *attributeName = @"dF";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name like %@",attributeName];
[fetchRequest setPredicate:predicate];
NSLog(@"predicate : %@",predicate);
NSError *error;
NSArray *items = [context executeFetchRequest:fetchRequest error:&error];
NSLog(@"items : %@",items);
[fetchRequest release];
//end of fetch
這裏是我的數據模型:
我想回到「DF」的價值,不應該這樣稱呼它? :
NSString *attributeName = @"dF";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name like %@",attributeName];
謂詞中的'name'是什麼?你的實體沒有屬性'name'! – vfn 2010-09-15 11:32:16
啊,那就是我很困惑的地方。我想返回名稱爲「dF」的屬性的值。 – 2010-09-15 11:39:18