Hey All,
I'm working on an iPad app that uses core data for storage. Users create objects (usually one a day) that contain many other objects themselves. The objects created daily each have a date (NSDate) and I have it right now that the table view only shows objects for a certain month (when the app launches, it's whatever month it currently is).
I'd like to let the user see all the objects created in a grouped table view. What I want is the header section to be the year, and each row in a section to be a month, with the textLabel set to the month and the detailLabel set to the number of objects created within that month. I'm using an NSFetchedResultsController to grab all the objects with year (a separate attribute, unless there's another way to get the year from the NSDate object) as the sectionKeyPath and can split the grouped table into sections with the year as the header. What I can't figure out how to do is to get the sections to then only show the months that have objects, with a count, instead of all the different objects themselves.
I tried using an NSMutableDictionary where the keys were the years and the objects were other nsmutabledictionary's were the keys were the months and the object stored was the count of objects. The problem I ran into was how to access them so that the years were in order and the months were in date order (as opposed to alphabetical) in the cellForRowAtIndexPath method...
Any ideas?
I'm working on an iPad app that uses core data for storage. Users create objects (usually one a day) that contain many other objects themselves. The objects created daily each have a date (NSDate) and I have it right now that the table view only shows objects for a certain month (when the app launches, it's whatever month it currently is).
I'd like to let the user see all the objects created in a grouped table view. What I want is the header section to be the year, and each row in a section to be a month, with the textLabel set to the month and the detailLabel set to the number of objects created within that month. I'm using an NSFetchedResultsController to grab all the objects with year (a separate attribute, unless there's another way to get the year from the NSDate object) as the sectionKeyPath and can split the grouped table into sections with the year as the header. What I can't figure out how to do is to get the sections to then only show the months that have objects, with a count, instead of all the different objects themselves.
I tried using an NSMutableDictionary where the keys were the years and the objects were other nsmutabledictionary's were the keys were the months and the object stored was the count of objects. The problem I ran into was how to access them so that the years were in order and the months were in date order (as opposed to alphabetical) in the cellForRowAtIndexPath method...
Any ideas?