Note that there are some explanatory texts on larger screens.

plurals
  1. POrelationship fault (core data)
    primarykey
    data
    text
    <p>I am new to core data and I need help with the following problem:</p> <p>I have two entities: Talk and Speaker. They have a to many relationship. </p> <p>Talk - destination: Speaker , inverse: talk Speaker - destination: Talk, inverse: speaker</p> <p>The field "To-Many Relationship" is checked on both entities. </p> <p>I have a table view controller to list all talks available. This is how am i doing:</p> <pre><code>- (NSFetchedResultsController *)fetchedResultsController { if (_fetchedResultsController != nil) { return _fetchedResultsController; } NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Talk" inManagedObjectContext:self.managedObjectContext]; [fetchRequest setEntity:entity]; NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO]; [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]]; [fetchRequest setFetchBatchSize:20]; NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"]; self.fetchedResultsController = theFetchedResultsController; _fetchedResultsController.delegate = self; return _fetchedResultsController; } </code></pre> <p>When i click on a cell, i want to load another view controller, showing only the details of the selected talk.</p> <p>This is what i am doing:</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { TalksDetailsViewController *talksDetails = [[TalksDetailsViewController alloc] initWithTalksInfo:[_fetchedResultsController objectAtIndexPath:indexPath]]; [self.navigationController pushViewController:talksDetails animated:YES]; } </code></pre> <p>The problem is: i can't see the speakers on TalksDetailsViewController. This is the info sent to TalksDetailsViewController:</p> <pre><code>Info: &lt;Talk: 0x6e66920&gt; (entity: Talk; id: 0x6e66880 &lt;x-coredata://4063FE84-E6DB-4588-8133-9A55B512D6C8/Talk/p2&gt; ; data: { date = "2012-08-31 03:00:00 +0000"; id = 7; speaker = "&lt;relationship fault: 0x6e994e0 'speaker'&gt;"; "start_time" = "17:14:55"; }) </code></pre> <p>I tried something as the code below, but it did not worked:</p> <pre><code>for (Speaker *speakerInfo in self.talkInfo.speaker) { NSLog(@"speaker info: %@", speakerInfo); } </code></pre> <p>It never gets into the for.</p> <p>If i try to log self.talkInfo.speaker i get something like:</p> <pre><code>Relationship 'speaker' fault on managed object (0x7a76c30) &lt;Talk: 0x7a76c30&gt; (entity: Talk; id: 0x7a76b90 &lt;x-coredata://4063FE84-E6DB-4588-8133-9A55B512D6C8/Talk/p2&gt; ; data: { date = "2012-08-31 03:00:00 +0000"; id = 7; speaker = "&lt;relationship fault: 0x6bc5990 'speaker'&gt;"; "start_time" = "17:14:55"; }) </code></pre> <p>I saw some similar questions, but could not fix my problem.</p> <p>Any tips?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload