Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming
by Maurice Sharp, Erica Sadun, Rod Strougo
Showing the Year in an Index
When you sort by year, you see only one or perhaps two index items. This is because the default title for an index is based on the first letter of whatever string is returned by the key. For the year property, the number is converted to a string, such as @"2012". Then the first character is added to the set of unique indexes. All the years in the current millennium are indexed by 2, and all from the previous millennium are indexed by 1. What you really want is to have the entire year used as the index title.
One way to do this is to create your own subclass of NSFetchedResultsController and specialize the implementation of sectionIndexTitleForSectionName: to return a custom string if the current sectionNameKeyPath ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access