I’m having issues in getting Core Data info from 3 linked entities. Some of it works, while some doesn’t.
Model
Entity Accounts RegDate
relationship heldby >> to-many >> inAccounts
attributes balance addDate
name
Entity RegDate Regster
relationship regheldBy >> to-many >> inRegDate
attributes addDate amount
When I do this:
Regster *regster = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = regster.amount;
NSLog(@"Regster: %@ %@", regster.amount, regster.inRegDate.addDate);
regster.amount displays the expected value, but regster.inRegDate.addDate null.
When I do this:
RegDate *regdate = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = regdate.addDate;
NSLog(@"RegDate: %@", regdate.addDate);
regdate.addDate displays the expected value, whereas previous example I get null.
Additionally, I cannot get amount to display.
I thought I could use: regdate.regheldBy.amount > but this give error “Property ‘amount’ not found on object of type ‘NSSet'”
Not sure what I’m doing wrong… I’m guessing I might have the relationships setup improperly. I’ve tried many different things, but can’t get it to work.
Any ideas?
It might be caused by not setting inverse relationships for all your relationships.
Also because
regdate.regheldByis a to-many relationship, it is represented by a set containingRegsterobjects. You can’t callamounton the set, you first have to select aRegsterobject from your set.