I want manage a chat with messages (as native iphone application) where in a first time only ten messages are displayed. Then, i want to be able to load and displayed ten others messages in the UItableview.I’ve found a method to add object in an array and after in the tableView :
-(IBAction)addCity:(id)sender
{
[dataArray addObject:@"City"];
NSArray *paths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:[dataArray count]-1 inSection:1]];
[[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationTop];
[tableView reloadData];
}
But my data are contained in a NSDictionnary (avatar, message, name).
Can i use the same method with a NSDictionnary ? How ?
Is there an other way ?
Thanks everyone for your help !
The basic problem is that when you’re asked to provide cell information, you have to be able to find it using two numbers: one number that matches a section in your table and another that matches a row within that section. Dictionaries aren’t very good at finding things by number; arrays are.
From what you’ve written, it sounds as if each message is in a dictionary. That suggests that — assuming your table only has one section — you need an array of dictionaries so that a dictionary can be found by row number and then the message portion put into a table cell.