title: Add cell/data to the top of UITableView
body: <p>I'm trying to create a simple chat application for iOS. It currently looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/8P8B3.png" alt="enter image description here"></p>
  
  <p>I want to change the order that the messages is displayed, i.e. display the latest message over the older messages. My current implementation looks like this:</p>
  
  <pre><code>// Datasource for the tableView
  messages  = [[NSMutableArray alloc] init];
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      [...]
      // messageTextView is a contentView subView.
      messageTextView.text = [messages objectAtIndex:indexPath.row];
      [...]
  
  - (IBAction)sendMessage:(id)sender
  {
      [messages addObject:messageField.text];
      messageField.text = @"";
      [self.tableView reloadData];
  
      /*
       I have tried the implementation below, but I always got an exception.
       [self.tableView beginUpdates];
       NSIndexPath *path1 = [NSIndexPath indexPathForRow:1 inSection:0]; 
       NSArray * indexArray = [NSArray arrayWithObjects:path1,nil]; 
       [self.tableView insertRowsAtIndexPaths:indexArray 
       withRowAnimation:UITableViewRowAnimationTop];
       [self.tableView endUpdates];
       */
  </code></pre>
  
  <p>}</p>
  
  <p>Any tips on how to do this would be great. </p>
  
  <p>Thanks.</p>