1
我有一个像实体中的以下内容:是否可以在NSFetchRequest的NSPredicate中使用父实体的属性?
@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>'
你能描述你的实体层次多一点,并显示你正在使用的实际谓词吗? – 2011-02-23 20:04:07
我已更新我的问题,更具体的代码片段。 – cmour 2011-02-24 22:40:38