title: swift 3 - delete table view cell from userDefaults
body: <pre><code>import Foundation
  
  class Persistence
  {
      let partiesKey = "parties"
      let namesKey = "names"
  
      func saveParty(party: Party)
      {
          let userDefaults = UserDefaults.standard
  
          var parties = fetchParties()
  
          parties.append(party)
  
          let data = NSKeyedArchiver.archivedData(withRootObject: parties)
  
          userDefaults.set(data, forKey: partiesKey)
          userDefaults.synchronize()
      }
  
      func fetchParties() -&gt; [Party]
      {
          let userDefaults = UserDefaults.standard
  
          let parties = userDefaults.object(forKey: partiesKey) as? Data
  
          if let parties = parties
          {
              return NSKeyedUnarchiver.unarchiveObject(with: parties) as! [Party]
          }
          else
          {
              return [Party]()
          }
      }
  
      func deleteParty(party: Party)
      {
          let userDefaults = UserDefaults.standard
  
          var parties = fetchParties()
  
      }
  
      func saveName(partyName: String)
      {
          var name = fetchName()
          name.append(partyName)
  
          let userDefaults = UserDefaults.standard
          userDefaults.set(name, forKey: namesKey)
          userDefaults.synchronize()
      }
  
      func fetchName() -&gt; [String]
      {
          let userDefaults = UserDefaults.standard
  
          let name = (userDefaults.value(forKey: namesKey) as? [String])
  
          return name ?? [String]()
      }
  }
  </code></pre>
  
  <p>Hi, I am very new to iOS programming. I am working on todo list for my first iOS app. I am trying to delete table view cell that is added by fetching and saving. I was able to save data and show name in the tableview cell. How do we delete table view cell in UserDefault?  func deleteParty() method will be called where the tableView cell is like this:</p>
  
  <pre><code>override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)
      {   
          if(editingStyle == .delete)
          {
              persistence.deleteParty(party: (parties?[indexPath.row])!)
              //tableView.deleteRows(at: [indexPath], with: .fade)
              tableView.reloadData()
          }
      }
  </code></pre>