I have an entity A like the following:
@interface A : NSManagedObject
{
}
@property (nonatomic, retain) NSString *stringProperty;
that has a subentity B like this:
@interface B : A
{
}
I would like to perform a fetch on B using a property stored in A. Something like this:
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];
Is this possible? I am currently getting the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath stringProperty not found in entity <NSSQLEntity B id=26>'
I just tried a similar example in the latest SDK (4.3) and it now works. I can now use the parent entities’ properties in a predicate for a subentity.