【发布时间】:2011-02-10 17:26:26
【问题描述】:
我有一个实体 A,如下所示:
@interface A : NSManagedObject
{
}
@property (nonatomic, retain) NSString *stringProperty;
有一个像这样的子实体 B:
@interface B : A
{
}
我想使用存储在 A 中的属性对 B 执行提取操作。如下所示:
NSManagedObjectContext *context = [delegate mainManagedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"B" inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDescription];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"stringProperty = %@", someString];
[request setPredicate:pred];
这可能吗?我目前收到以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath stringProperty not found in entity <NSSQLEntity B id=26>'
【问题讨论】:
-
您能否再描述一下您的实体层次结构并显示您正在使用的实际谓词?
-
我已经用更具体的代码 sn-ps 更新了我的问题。
标签: iphone ios core-data nspredicate