In Core data, I have three types of entities. Entity A, Entity B, Entity C
Entity C to entity A is a one to many relationship. Entity C to entity B is also a one to many relationship.
In another word, Both A and B has an inRecord
field which points to a single instance of Entity C.
I have the following code
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"EntityA"];
request.predicate = [NSPredicate predicateWithFormat:@"inRecord.title = %@", title];
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES];
request.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSError *error = nil;
NSArray *arrayOfEntity = [context executeFetchRequest:request error:&error];
Now if I check the class of arrayOfEntity[0], it will say it is of class EntityA. However, with the exact same code, if I replaced EntityA by EntityB above, if I check the class of arrayOfEntity[0], it does not say EntityA, instead, it says it is class NSManagedObject.
Why is that?