title: Having trouble editing and saving a note in my tableview in swift?
body: <p>Im having trouble editing and saving a note in my tableview. Ill give you an example, when I add a note to the tableview and then go and edit it it works perfectly. But when I add another note and then try to edit it and save it the note that I first added deletes from the tableview for some reason. I don t get why that happens. Here is the code I use for when I want to edit and save a note. </p>
  
  <pre><code>@IBAction func saveAndEditNote(sender: AnyObject) {
  
      let userDefaults: NSUserDefaults = NSUserDefaults.standardUserDefaults()
  
      let itemList: NSMutableArray? = userDefaults.objectForKey("itemList") as? NSMutableArray
  
      let dataSet: NSMutableDictionary = NSMutableDictionary()
      dataSet.setObject(detailTextView.text, forKey: "text")  
  
      if ((itemList) != nil) {       
          let newMutableList: NSMutableArray = NSMutableArray()
          newMutableList.addObject(dataSet)
          userDefaults.setObject(newMutableList, forKey: "itemList")
  
      }
  
      userDefaults.synchronize()
      self.navigationController?.popToRootViewControllerAnimated(true)
      self.navigationController?.setNavigationBarHidden(false, animated: true)
      self.navigationController?.toolbarHidden = false    
  }
  </code></pre>