I did try that. It doesn't quite work correctly (and you can see this behavior in the core data sample app.)
In the core data sample application, create the following people:
Abby, Brian, Carry, Daphne, Isaac, Joseph, Kelly, Larry, Mariah, Nancy, Perry, Randy, Sam, Terry, Verra
Now, click / tap each letter in the index. A, B, C, D work correctly. E takes you to the "I" section;
not unreasonable since that is the next existing section after E that exists. F takes you to the "J"
section, G to the "K" section, H to the "L" section, and I to the "M" section, which is dead wrong as
there is an "I" section.
By implementing the tableView:sectionForSectionIndexTitle:atIndex:, I presume I could tell the table view controller that the sectionIndex at index 8 (the "I" sectionIndex") should map to the Section index 4 (section for I contain "Isaac") So the question is how can I hook into STV to tell it that the sectionIndex index != to the section index?
I'd love it if STV just got this right. I'm not sure how hard that would be in the general case... especially in view of internationalization and localization challenges.
PS. Just in case it wasn't clear, tableView:sectionForSectionIndexTitle:atIndex: is from UITableViewDataSource, and the apple documentation says the following:
Asks the data source to return the index of the section having the given title and section title index.
The table-view object requesting this information.
The title as displayed in the section index of tableView.
An index number identifying a section title in the array returned by sectionIndexTitlesForTableView:.
An index number identifying a section.
This method is passed the index number and title of an entry in the section index list and should return the index of the referenced section. To be clear, there are two index numbers in play here: an index to an section index title in the array returned by sectionIndexTitlesForTableView:, and an index to a section of the table view; the former is passed in, and the latter is returned. You implement this method only for table views with a section index list—which can only be table views created in the plain style (UITableViewStylePlain). Note that the array of section titles returned by sectionIndexTitlesForTableView:can have fewer items than the actual number of sections in the table view.
Edited by email@example.com, 24 July 2013 - 02:33 PM.