When you load the data for your table -- whether that's using NSFetchedResultsController
and Core Data, or loading a .plist file into an NSDictionary
object -- you can "section" it as you like.
You'll first step through the data (e.g. use the fetchedObjects
property if using NSFetchedResultsController
) and determine what sections you want. Since you're wanting to split on dates, you might store cutoffs represented by NSDate
objetcts in an array. You would then use this array to implement the various UITableViewDataSource
methods: in numberOfSectionsInTableView:
you can return the count
of this array, and in sectionIndexTitlesForTableView:
you can return NSString
representations of those stored NSDate
s for the section titles.
Methods like tableView:numberOfRowsInSection:
and tableView:cellForRowAtIndexPath:
are a little trickier. You'll probably want to use another "preprocessed" data structure (perhaps a two-level array of arrays, where the inner arrays contain the entity objects you fetched), and you'll want to set up as the same time as your array of NSDate
objects.