title: NSKeyedArchiver.archiveRootObject returns "false" if I want to overwrite data, why?
body: <pre><code>NSKeyedArchiver.archiveRootObject(&lt;#rootObject: AnyObject#&gt;, toFile: &lt;#String#&gt;)
  </code></pre>
  
  <p>Only returns true the first time. Every next time I call it, the method returns false.</p>
  
  <p>I read some SO, some posts said that I can't rewrite data this way. However, I tried : </p>
  
  <pre><code> NSFileManager.defaultManager().removeItemAtPath(path, error: nil) 
  </code></pre>
  
  <p>and it still didn't help. </p>
  
  <p>What I did:</p>
  
  <ol>
  <li>Checked all my model files for the <code>NSCoding</code> protocol</li>
  <li>Checked all my <code>required init(coder aDecoder: NSCoder)</code> and <code>func encodeWithCoder(aCoder: NSCoder)</code></li>
  </ol>
  
  <p>I am missing something, since I have done this in my last app and it worked fla`</p>
  
  <pre><code>import Foundation
  
      private let ON_DISK_DATA_DICTIONARY    = "savedDataPathsOnDisk"
      private let _WBMAccessDataOnDiskMShared = WBMAccessDataOnDiskM()
      private var dataDirectories:NSArray!   = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
      private var dataDirectoryURL:NSURL!    = NSURL(fileURLWithPath: dataDirectories.objectAtIndex(0) as! String, isDirectory: true)
      private var dataDirectoryPath:String!  = dataDirectoryURL.path!
  
      let FILE_FORMAT = ".archive"
  
      class WBMAccessDataOnDiskM: NSObject
      {
          class var sharedData: WBMAccessDataOnDiskM
          {
              return _WBMAccessDataOnDiskMShared
          }
  
          private var dataAndPathDictionary = [String:String]()
  
          func getDataAndPathDictionary() -&gt; [String:String]
          {
              return self.dataAndPathDictionary
          }
  
          func addDataAndPathToDictionary(data:String ,path:String)
          {
              if !checkIfDataAllreadyExists(data)
              {
                  let fullPath                = createFullDataPath(path)
                  dataAndPathDictionary[data] = fullPath
                  NSUserDefaults.standardUserDefaults().setObject(dataAndPathDictionary, forKey: ON_DISK_DATA_DICTIONARY)
              }
          }
  
          func checkIfDataIsAvailable(dataPathComponent:String) -&gt; (Bool,String)
          {
              var paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! String
              var dataPath = paths.stringByAppendingPathComponent(dataPathComponent)
              var checkValidation = NSFileManager.defaultManager()
  
              println(dataPathComponent)
  
              if (checkValidation.fileExistsAtPath(dataPath))
              {
                  return (true,dataPath)
              }
              else
              {
                  return (false,"")
              }
          }
  
          func checkForDataOnDisk() -&gt; Bool
          {
              let dataDict = NSUserDefaults.standardUserDefaults().objectForKey(ON_DISK_DATA_DICTIONARY) as? [String:String]
  
              if dataDict == nil
              {
                  return false
              }
              else
              {
                  dataAndPathDictionary = dataDict!
                  return true
              }
          }
  
          private func checkIfDataAllreadyExists(data:String) -&gt; Bool
          {
              let keys = self.dataAndPathDictionary.keys.array
              if contains(keys, data)
              {
                  return true
              }
              return false
          }
  
          private func createFullDataPath(path:String) -&gt; String
          {
              var fullPathURL = dataDirectoryURL.URLByAppendingPathComponent(path + FILE_FORMAT)
              return fullPathURL.path!
          }
  
          func saveDataArray(data:[AnyObject], path:String)
          {
              NSFileManager.defaultManager().removeItemAtPath(path, error: nil)
  
              if NSKeyedArchiver.archiveRootObject(data, toFile: path)
              {
                 // SAVING
                  println(" Saving data ARRAY ")
              }
              else
              {
                  println(" NOT saving data ARRAY ")
              }
          }
  
          func saveDataObject(dataObject:AnyObject, path:String)
          {
              if NSKeyedArchiver.archiveRootObject(dataObject, toFile: path)
              {
                  println(" Saving data OBJECT ")
              }
              else
              {
                  println(" NOT saving data OBJECT ")
              }
          }
  
          // dataFromDisk = NSKeyedUnarchiver.unarchiveObjectWithFile(pathForNews) as? [AnyObject]
          func loadDataArray(path:String) -&gt; [AnyObject]?
          {
              var dataArrayFromDisk: [AnyObject]?
              dataArrayFromDisk = NSKeyedUnarchiver.unarchiveObjectWithFile(path) as? [AnyObject]
  
              return dataArrayFromDisk
          }
  
          func loadDataObject(path:String) -&gt; AnyObject?
          {
              var dataObjectFromDisk: AnyObject?
              dataObjectFromDisk = NSKeyedUnarchiver.unarchiveObjectWithFile(path)
              return dataObjectFromDisk
          }
  
          func getNewsDataLanguagePath() -&gt; String
          {
              var currentOSLanguage = LOCALIZATION.currentOsLanguage
              currentOSLanguage     = currentOSLanguage.substringToIndex(2)
              if currentOSLanguage == "de"
              {
                  return ON_DISK_CONTENT_DE
              }
              else if currentOSLanguage == "en"
              {
                  return ON_DISK_CONTENT_ENG
              }
              return ON_DISK_CONTENT_ENG
          }
      `
  </code></pre>
  
  <p>I am using Xcode 6.4 and Swift 1.2.</p>
  
  <p>Any help &amp; code correction is welcome.</p>