My second post here. I'm still very new to core data for IOS. I've read through the apple developer page, but I still don't understand exactly how to implement the code.
I have 2 entities with relationship: Student <----->> StudentInfo
Student properties (strings): firstname, lastname, studentid
StudentInfo properties (strings): itemA, itemB, itemC
Since each Student has many StudentInfos, how would I go about accomplishing the task of finding only the entities with (itemA == "abc") and displaying the related Student's studentid along with itemC?
edit
NSEntityDescription *entitydesc = [NSEntityDescription entityForName:@"Student" inManagedObjectContext:self.managedObjectContext];
NSFetchRequest *req = [[NSFetchRequest alloc] init];
[req setEntity:entitydesc];
NSPredicate *predi = [NSPredicate predicateWithFormat:@"studentid like %@", self.idTextField.text];
[req setPredicate:predi];
NSError *error;
NSArray *matchingData = [self.managedObjectContext executeFetchRequest:req error:&error];
if (matchingData.count <= 0) {
self.testLabel.text = @"nada found";
} else {
NSString *firstName;
NSString *lastName;
for (NSManagedObject *obj in matchingData) {
firstName = [obj valueForKey:@"firstname"];
lastName = [obj valueForKey:@"lastname"];
}
self.testLabel.text = [NSString stringWithFormat:@"%@%@", firstName, lastName];
}
I got this much so far and this works great for accessing data from the main Student entity, but how would I go about accessing attributes of a specific case of entity StudentInfo?
... Sorry for any improper formatting, and thank you in advance for the help!