title: UITableView Crashes if Data Source Is Updated During Scrolling
body: <p>I have an app wherein the datasource for a UITableView updates by a background thread from a remote server every 30 seconds.</p>
  
  <p>A crash occurs if the user is scrolling the tableView or if the tableView is in process of <code>reloadTableView:</code>. The reason for crash is that number of rows in table at the time of the crash doesn't match the number of rows at the time the redraw started.</p>
  
  <p>Another crash happens when a requested TableView cell is out of range because, between the time <code>numberofTableViewCells:</code> is  called and the time <code>cellfForRowAtIndexPath</code> is called, the datamodel has changed and the cell is no longer there.</p>
  
  <p>The data for the tableView is updated from a background thread. While data is loaded from a server, the user should still be able to interact with tableView but right now that causes a crash.</p>
  
  <p>How do I block the tableView from scrolling or reloading while I update tableViewDataSource?
  What is the best practice for this kind of situation?</p>
  
  <p>Thanks.</p>