I am trying to add new data to a UITableView in two ways.
First way
func insertData(appendMessages:[Message]) { var currentCount = self.messeges.count; var indxesPath:[NSIndexPath] = [NSIndexPath]() for msg in appendMessages { indxesPath.append(NSIndexPath(forRow:currentCount,inSection:0)); self.messeges.append(msg) currentCount++ } self.tableView.beginUpdates() self.tableView.insertRowsAtIndexPaths(indxesPath, withRowAnimation: UITableViewRowAnimation.Bottom) self.tableView.endUpdates() }
Second way
func insertData(appendMessages:[Message]) { for msg in appendMessages { self.messeges.append(msg) } self.tableView.reloadData() }
You see that I shared the results.
When using "reloadData" everything works fine, but I think this is not a good reason, am I updating everything, and not new content?
When using "insertRowsAtIndexPaths", I have a duplicated separator, and the line is colored only when I click on it.
It's weird what I'm doing wrong ...
thanks
Shay


source share