title: Nil relationship value for section name key path in nsfetchedresultscontroller
body: <p>For a core data model where EntityA has a many-to-one relationship with EntityB, I want to create a list of EntityA objects, sorted by the name of the EntityB they are related to. Normally to do this I would set up the fetch request like this:</p>
  
  <pre><code>if (_fetchedResultsController != nil) {
      return _fetchedResultsController;
  }
  
  NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
  </code></pre>
  
  <p>Then I would set up my request's values: (in this case it's a list of plants sorted by species name. some plants have no species set.)</p>
  
  <pre><code>NSEntityDescription *entity = [NSEntityDescription entityForName:@"Plant" inManagedObjectContext:self.managedObjectContext];
  NSSortDescriptor *sortDescriptorOne = [[NSSortDescriptor alloc] initWithKey:@"species.name" ascending:YES];
  NSString *sectionKeyPath = @"species.name";
  </code></pre>
  
  <p>Then I finish it up with the usual stuff:</p>
  
  <pre><code>[fetchRequest setEntity:entity];
  
  // Set the batch size to a suitable number.
  [fetchRequest setFetchBatchSize:20];
  
  NSArray *sortDescriptors = @[sortDescriptorOne];
  [fetchRequest setSortDescriptors:sortDescriptors];
  
  NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
  managedObjectContext:self.managedObjectContext
  sectionNameKeyPath:sectionKeyPath
  cacheName:@"plantsCache"];
  
  aFetchedResultsController.delegate = self;
  self.fetchedResultsController = aFetchedResultsController;
  
  [NSFetchedResultsController deleteCacheWithName:@"plantsCache"];
  NSError *error = nil;
  if (![self.fetchedResultsController performFetch:&amp;error]) {
      NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
      abort();
  }
  
  return _fetchedResultsController;
  </code></pre>
  
  <p>But the result I get isn't working for me because the relationship is optional. So some of EntityA have a relationship to EntityB's and some don't. The results controller doesn't seem to know what to do when the value of EntityA's relationship is nil.</p>
  
  <p>Any suggestions what I can do to continue making sections using the relationship's value but allowing some objects to have nil for it?</p>