I store dates in a core data entity attribute, I then display the date in the table cells. I want to group all the cells according to months and only display the relevant da
Apple has a really great sample showing exactly how you can achieve this. I think it is what you are looking for.
Check out: http://developer.apple.com/library/ios/#samplecode/DateSectionTitles/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009939
Step one, make sure you have a Managed Object Class in your project that represents the core data entity that stores the date. Step two, in the implementation file for this entity, write a method that returns the month for that object. It should look at the date variable and use NSDateComponents
methods to determine the month. You need not create a new attribute for it. Step three, when you initialize your NSFetchedResultsController, pass the name of the method that returns the month as the sectionNameKeyPath
parameter. What you are essentially doing is creating a "getMonth" method that programmatically determines the month, and giving the value returned by that to the sectionNameKeyPath. I hope this is clear. Please ask for clarification if not.
Note. Make sure your month method returns the month in a way that sorts in the proper order (ie not alphabetically), and that your Table View translates that into a meaningful string.