Iphone 是否可以使用父实体';NSFETCH请求的NSPredicate中的s属性?

Iphone 是否可以使用父实体';NSFETCH请求的NSPredicate中的s属性?,iphone,ios,core-data,nspredicate,Iphone,Ios,Core Data,Nspredicate,我有一个实体A,如下所示: @interface A : NSManagedObject { } @property (nonatomic, retain) NSString *stringProperty; 其子实体B如下所示: @interface B : A { } NSManagedObjectContext *context = [delegate mainManagedObjectContext]; NSEntityDescription *entityDescription

我有一个实体A,如下所示:

@interface A : NSManagedObject
{
}

@property (nonatomic, retain) NSString *stringProperty;
其子实体B如下所示:

@interface B : A
{
}
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];
我想使用存储在a中的属性对B执行提取。类似于以下内容:

@interface B : A
{
}
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>'
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“在实体中找不到keypath stringProperty”

您需要调用
超级实体吗?即

[NSPredicate predicateWithFormat:@"superentity.stringProperty = %@", someString];

或者,您可以为您的获取请求获取实体A和
setIncludesSubAuthentications:YES

我刚刚在最新的SDK(4.3)中尝试了一个类似的示例,现在它可以工作了。现在,我可以在子实体的谓词中使用父实体的属性。

您能更详细地描述您的实体层次结构并显示您正在使用的实际谓词吗?我已经用更具体的代码片段更新了我的问题。谢谢您的回答。这么长时间没有人回应,我继续前进,正如我所记得的,我只是改变了我的等级制度。当我有时间时,我将尝试您的解决方案并相应地接受您的答案。我尝试使用superentity.stringProperty并出现以下错误:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因是:“在entity中也未找到keypath superentity.stringProperty,setIncludesSubentities:是不是一个选项,因为我只希望结果中有B个实体。