title: Get NSFetchedResultsController section object from UICollectionView's viewForSupplementaryElementOfKind
body: <p>I have a data model called <code>Location</code>. I use these as my section headers in a <code>UICollectionViewController</code>. Each <code>location</code> can display <code>items</code> inside these sections. I want to customise my section headers in <code>viewForSupplementaryElementOfKind</code>. But I can't figure out how to recive the correct <code>Location</code> objects from this method.</p>
  
  <p>I have tried things like: </p>
  
  <pre><code>-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView   viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
  {
  
      id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [self.fetchedResultsController sections] [indexPath.section];
      Item *item = sectionInfo.objects[0];
      Location *location = item.location;   
      SectionHeaderView *headerView = [collectionView   dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader   withReuseIdentifier:@"SectionHeader" forIndexPath:indexPath];
      headerView.label.text = location.name;
      [...]
  </code></pre>
  
  <p>But I keep getting: </p>
  
  <pre><code>Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM   objectAtIndex:]: index 0 beyond bounds for empty array'
  </code></pre>
  
  <p>This is probably because it's possible to have Location without any items. Any other ideas on how I should do it?</p>