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 ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.