title: Save Data to .plist File in Swift
body: <p>I am trying to save data to a plist file in swift, but the data isn't showing up as it was saved when the plist is read.  This is the code I was using.</p>
  
  <pre><code>var documentsDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
  var path : NSString = documentsDirectory.stringByAppendingPathComponent("data.plist")
  var data : NSMutableDictionary = NSMutableDictionary(contentsOfFile: path)
  data.setObject(self.object, forKey: "key")
  data.writeToFile(path, atomically: true)
  </code></pre>
  
  <p>Edit:  I've heard that the best way to do this is write to the documents directory, so my question would be how should I write to a file in that directory?</p>