title: Removing a single key value of UserDefaults in Swift 3
body: <p>I am tracking a user's preferences in my iOS app using <code>UserDefaults</code> -- when a user selects a table cell, it adds the cell's text to my key. That part works.</p>
  
  <p>Now, I want to allow the user to remove the matching key value from the key when a row is selected. If a cell says "Episode 1", it should remove the value from <code>UserDefaults</code>.</p>
  
  <p>From <a href="https://developer.apple.com/documentation/foundation/userdefaults/1411182-removeobject" rel="nofollow noreferrer">the documentation</a>, there's an instance method for <code>removeObject</code>. Here's what I wrote: </p>
  
  <pre><code>    let defaults = UserDefaults.standard
      var myarray = defaults.stringArray(forKey: "SavedStringArray") ?? [String]()
      if let datastring = TableData[indexPath.row] as? String {
          if !myarray.contains(datastring) {
              myarray.append(datastring)
              defaults.removeObject(myarray, forKey: "SavedStringArray")
              defaults.synchronize()
          }
  </code></pre>
  
  <p>This returns an error for <code>Extra argument in call</code> -- I assume it means <code>myarray</code>, but if I can't add that argument, how can I tell it to remove only one value (stored in <code>myarray</code>)? </p>
  
  <p>If I print the <code>UserDefaults.standard</code>, it will return a list of stored episode values like `["First Episode", "Second Episode", "Third Episode"] </p>
  
  <p>Any idea how I can remove <code>Third Episode</code> when that cell is clicked here? </p>