title: Core Data One-To-Many Fetch Data
body: <p>Okay I have a one-to-many relationship in core data.  A Meal can consists of many different Food.  My code doesn't quite seem to be working in the Fetch Controller.  I can say this with confidence, the self.meal is the current Meal I am trying to fetch.  I am sharing the context through out the application.</p>
  
  <p>The problem I am having is that the application is displaying foods but it doesn't quite seem to match up against what should be inside of a Meal.  As soon as I add a food, it immediately displays that, even if it is not inside of the Meal.</p>
  
  <p>Any help or suggestion, I am doing this fetch correctly.</p>
  
  <pre><code>- (NSFetchedResultsController *)fetchedResultsController 
  {       
      self.context = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; 
  
      if (_fetchedResultsController != nil) {
          return _fetchedResultsController;
      }
  
      NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
      NSEntityDescription *entity = [NSEntityDescription entityForName:@"Food" inManagedObjectContext:self.context];
  
      [fetchRequest setEntity:entity];
  
  
      NSPredicate *foodPredicate = [NSPredicate predicateWithFormat:@"meals == %@", self.meal];
      [fetchRequest setPredicate:foodPredicate];
  
      NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
      [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];
      [fetchRequest setFetchBatchSize:20];
  
      NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.context sectionNameKeyPath:nil cacheName:@"Root"];
  
  
      self.fetchedResultsController = theFetchedResultsController;
      _fetchedResultsController.delegate = self;
  
      [fetchRequest release];
      [theFetchedResultsController release];
  
      return _fetchedResultsController;
  }
  </code></pre>