title: NSFetchedResultsController doesn't respond to changes in the number of sections
body: <p>I'm getting the following error when I delete a cell from the table view:</p>
  <blockquote>
  <p>Invalid update: invalid number of sections. The number of sections
  contained in the table view after the update (0) must be equal to the
  number of sections contained in the table view before the update (1),
  plus or minus the number of sections inserted or deleted (0 inserted,
  0 deleted)</p>
  </blockquote>
  <p>I'm using the <code>NSFetchedResultsControllerDelegate</code> to respond to the changes in the number of section. I'm retrieving the data from a plist file in Core Data and each addition of the table view cell increases the number of sections accordingly, so 3 cells = 3 sections.</p>
  <pre class="lang-swift prettyprint-override"><code>override func numberOfSections(in tableView: UITableView) -&gt; Int {
      return fetchedResultsController.sections?.count ?? 0
  }
  
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      let sectionInfo = fetchedResultsController.sections![section]
      return sectionInfo.numberOfObjects
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: &quot;Cell&quot;, for: indexPath)
      let goal = fetchedResultsController.object(at: indexPath)
      cell.textLabel!.text = goal.title
      return cell
  }
  
  override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
      if editingStyle == .delete {
          let goal = fetchedResultsController.object(at: indexPath)
          self.context.delete(goal)
          self.saveContext()
      }
  }
  
  func controller(_ controller: NSFetchedResultsController&lt;NSFetchRequestResult&gt;, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
      switch type {
      case .delete:
          tableView.deleteRows(at: [indexPath!], with: .automatic)
      default:
          break
      }
  }
  
  func controller(_ controller: NSFetchedResultsController&lt;NSFetchRequestResult&gt;, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType) {
      let section = IndexSet(integer: sectionIndex)
      switch type {
      case .delete:
          tableView.deleteSections(section, with: .automatic)
      default:
          break
      }
  }
  </code></pre>
  <p><code>context</code> is this:</p>
  <pre class="lang-swift prettyprint-override"><code>var context : NSManagedObjectContext {
      let appDelegate = UIApplication.shared.delegate as! AppDelegate
      return appDelegate.persistentContainer.viewContext
  }
  </code></pre>
  <p>How I load the saved Core Data onto FRC:</p>
  <pre><code>func loadSavedData() {
      if fetchedResultsController == nil {
          let request = Goal.createFetchRequest()
          let sort = NSSortDescriptor(key: &quot;date&quot;, ascending: false)
          request.sortDescriptors = [sort]
          request.fetchBatchSize = 20
          
          fetchedResultsController = NSFetchedResultsController(fetchRequest: request, managedObjectContext: self.context, sectionNameKeyPath: &quot;title&quot;, cacheName: nil)
          fetchedResultsController.delegate = self
      }
      
      fetchedResultsController.fetchRequest.predicate = goalPredicate
      
      do {
          try fetchedResultsController.performFetch()
          tableView.reloadData()
      } catch {
          print(&quot;Fetch failed&quot;)
      }
  }
  </code></pre>