Suppose I have a UITableViewController with an array "history" as data source. The array consists of an undefined number of NSDictionaries. Each dictionary contains the following keys: term (NSString), date (NSDate) and id (NSNumber).
I would like to map the contents of the history array according to the date values each dictionary has, i.e. I need to dynamically create sections, named and sorted according to the date values of each dictionary (the iPhone app wikipanion does this in its history vi开发者_如何转开发ew). Is there a best practice to do this? Otherwise I would just read out each date object, sort them into another dictionary, etc...
Best practice is to 'group by YYYY-MM-DD' and then 'sort by YYYY-MM-DD HH:MM:SS'. So this involves some simple grouping of your dictionaries into arrays. Now that you have an array of arrays you can sort those simply by date.
精彩评论