I'm working on an app which uses a UITableView to display content over a time period. The idea is that each section should be a day, and each day can have a varying number of objects, each of which appear as a list item. Easy enough.
The objects are stored in one NSArray, which contains an NSDate, the Text which should be displayed in the list and some other stuff.
I'm trying to implement the
and
methods, but am somewhat stuck.
The first method has to work out how many distinct days there are in the NSArray, I think, but there's no obvious method to do this. I can use an NSDateFormatter to just get the date and ignore the time, but then it's a problem finding how many distinct strings there are (since containsObject() won't have the same object for the two 'different NSStrings with the same text (I think?).
Anyway, before I plough head first into this and redo my datastructure or implement some highly inefficient algorithm, I was wondering if anyone here has tackled something similar and perhaps has some inspiration
The objects are stored in one NSArray, which contains an NSDate, the Text which should be displayed in the list and some other stuff.
I'm trying to implement the
Code:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
The first method has to work out how many distinct days there are in the NSArray, I think, but there's no obvious method to do this. I can use an NSDateFormatter to just get the date and ignore the time, but then it's a problem finding how many distinct strings there are (since containsObject() won't have the same object for the two 'different NSStrings with the same text (I think?).
Anyway, before I plough head first into this and redo my datastructure or implement some highly inefficient algorithm, I was wondering if anyone here has tackled something similar and perhaps has some inspiration