title: App crash: 'attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update
body: <p>In my tableView </p>
  
  <pre><code>func numberOfSections(in tableView: UITableView) -&gt; Int {
  
          print("numberOfsection Call")
          return 1
      }
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
  
          print("numberOfRows Call")
          if places.count &lt; self.numberPlaces {
             return  places.count
        }
         return self.numberPlaces
      }
  </code></pre>
  
  <p>the application is going in a crash for this error: </p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update</p>
  </blockquote>
  
  <p>after I added this animation</p>
  
  <pre><code>    func insertRowsMode3() {            
          numberPlaces = 0
          insertRowMode3(ind: 0)
      }
  
      func insertRowMode3(ind:Int) {
  
          let indPath = IndexPath(row: ind, section: 0)
          numberPlaces = ind + 1
          tableView.beginUpdates()
          tableView.insertRows(at: [indPath], with: .right)
          tableView.endUpdates()
  
          guard ind &lt; places.count-1 else { return }
          DispatchQueue.main.asyncAfter(deadline: .now()+0.20) {
  
              self.insertRowMode3(ind: ind+1)
          }
  
      }
  </code></pre>
  
  <p>What is wrong whit it? There is a way to create the same animation that does not crash the app?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>public  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
          let cell = tableView.dequeueReusableCell(withIdentifier: resueIdentifier, for: indexPath) as! MyTableViewCell
          cell.delegate = self
          cell.myCellNumber.text = "\(indexPath.row + 1)"
          cell.tag = indexPath.row
          cell.refButton.addTarget(self, action: #selector(CourseClass2.reloadCell(_:)), for: .touchUpInside)
          let place = sortedArray[indexPath.row]
          cell.update(place: place)
          cell.selectionStyle = .none
  
           if indexPath.row == places.count - 1 {
              CarTo(false)
          }
          print("CellForRow Call")
          return (cell)
  
         }
  </code></pre>