title: A-Z Index from NSFetchedResultsController with individual section headers within each letter?
body: <p>I have an <code>NSFetchedResultsController</code> which fetches data from a Core Data structure, a list of albums. It's currently sorted by the artist, so all the A's, B's, etc. I want to add an index so the user can quickly jump to each letter, and I'm using the code below to do it. The issue is that the section headers are now "A", "B", "C", etc., too, meaning I've lost the section headers in alphabetical order with each individual artist on it ("Adele", "America", "Beatles, The", etc.)</p>
  
  <p>I'd like the index to use the letters A through Z, but the section headers to display the artist names in alphabetical order. Pushing a letter in the index would then jump to the first artist with that letter. How can I achieve this (alphabet characters in the index, but a different attribute for the section titles)?</p>
  
  <p><strong>EDIT:</strong> If I set my <code>sectionNameKeyPath</code> to my <code>author</code> field, the A-Z index is visible, but the letters aren't synced up to the names, for example if I tap S, it takes me to artists beginning with AL, or tapping G takes me to AB. I'm not quite sure why this is, perhaps the section index is screwing up?</p>
  
  <p>Here's the code I'm using:</p>
  
  <p><strong>In my <code>NSManagedObject</code> subclass:</strong></p>
  
  <pre><code>- (NSString *) firstLetter
  {
      [self willAccessValueForKey: @"firstLetter"];
      NSString *firstLetter = [[[self author] substringToIndex: 1] uppercaseString];
      [self didAccessValueForKey: @"firstLetter"];
      return firstLetter;
  }
  </code></pre>
  
  <p><strong>In my View Controller, to create the FRC:</strong></p>
  
  <pre><code>NSFetchedResultsController *byAuthorFRC = [[NSFetchedResultsController alloc] initWithFetchRequest: _fetchRequest
                                                                                managedObjectContext: [[CDManager sharedManager] managedObjectContext]
                                                                                  sectionNameKeyPath: @"firstLetter"
                                                                                           cacheName: nil];
  </code></pre>
  
  <p><strong>And here's my <code>sectionIndexTitlesForTableView:</code> method:</strong></p>
  
  <pre><code>- (NSArray *) sectionIndexTitlesForTableView: (UITableView *) tableView
  {
      return [self.fetchedResultsController sectionIndexTitles];
  }
  </code></pre>