title: UITableView didDeselectRowAtIndexPath delegate method not called after programmatically selecting row
body: <p>I have a custom class (superclass <code>UITableViewController</code>).</p>
  
  <p>I have an add button that:</p>
  
  <ol>
  <li>Begins table updates.</li>
  <li>Inserts row in table.</li>
  <li>Ends table updates.</li>
  <li>Calls <code>selectRowAtIndexPath</code>.</li>
  <li>Calls <code>didSelectRowAtIndexPath</code>.</li>
  </ol>
  
  <p>Unfortunately, <code>didDeselectRowAtIndexPath</code> is not being called after programatically selecting a row.</p>
  
  <p>Note: Using Swift (not Objective-C).</p>
  
  <pre><code>@IBAction func addButton(sender: UIBarButtonItem) {
      let indexPathZero: NSIndexPath = NSIndexPath(forRow: 0, inSection: 0)
      todoController.addNewTodoItem(nameOfItem: "test5")
  
      self.tableView.beginUpdates()
      self.tableView.insertRowsAtIndexPaths([indexPathZero], withRowAnimation: UITableViewRowAnimation.Top)
      self.tableView.contentOffset.y = 64
      self.tableView.endUpdates()
  
      // Ask user for input
      editCell(indexPathZero)
  }
  
  func editCell(indexPath: NSIndexPath) {
      self.tableView.selectRowAtIndexPath(indexPath, animated: true, scrollPosition: UITableViewScrollPosition.None)
      self.tableView(self.tableView, didSelectRowAtIndexPath: indexPath)
  }
  </code></pre>
  
  <p><strong>Solution</strong></p>
  
  <pre><code>let indexPathZero: NSIndexPath = NSIndexPath(forRow: 0, inSection: 0)
      todoController.addNewTodoItem(nameOfItem: "test5")
  
      let currSelectedIndexPath = self.tableView.indexPathForSelectedRow()
  
      if currSelectedIndexPath != nil {
          self.tableView.deselectRowAtIndexPath(currSelectedIndexPath!, animated: true)
          self.tableView(self.tableView, didDeselectRowAtIndexPath: currSelectedIndexPath!)
      }
  
      self.tableView.beginUpdates()
      self.tableView.insertRowsAtIndexPaths([indexPathZero], withRowAnimation: UITableViewRowAnimation.Top)
      self.tableView.contentOffset.y = 64
      self.tableView.endUpdates()
  
      // Ask user for input
      editCell(indexPathZero)
  </code></pre>