title: How to delete TableViewCell that being a Dictionary Swift
body: <p>I am trying to delete a table view cell using swipe to delete, but I can't use the line I marked in my code, not sure why. My cells are being made by a Dictionary, with the key for the title and the value for the details.</p>
  
  <pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
     let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
  
      //Create the cell by the dictionary favDict
      for (key, value) in favDict{
          cell.textLabel?.text = key
          cell.detailTextLabel?.text = value
      }
  
      return cell
  }
  
  func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -&gt; Bool {
      return true
  }
  
  func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) {
      if editingStyle == UITableViewCellEditingStyle.Delete {
          favDict.removeAtIndex(indexPath!.row)// Line that is giving the error says Int is not convertible for [String: String]
          tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
      }
  }
  </code></pre>
  
  <p>Resolution: </p>
  
  <pre><code>import UIKit
  
  class ViewController2: UIViewController, UITableViewDelegate {
  
      var dictKeys : [String]?
  
      @IBOutlet var tableView: UITableView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view.
          dictKeys = Array(favDict.keys)
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          dictKeys = Array(favDict.keys)
          return rowsInSec
      }
  
  
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
  
          let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
          var key = dictKeys?[indexPath.row]
          var data = favDict[key!]
          cell.textLabel?.text = key
          cell.detailTextLabel?.text = data
  
           return cell
      }
  
  
      func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -&gt; Bool {
          return true
      }
  
      func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) {
          if editingStyle == UITableViewCellEditingStyle.Delete
          {
              var key  = dictKeys?[indexPath.row]
              favDict.removeValueForKey(key!)
              dictKeys?.removeAtIndex(indexPath.row)
              rowsInSec--
              tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
          }
          }
      }
  </code></pre>