title: Saving to User Defaults in Swift
body: <p>I am currently trying to save an array to the user defaults.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>//where things will be stored
  let defaults = NSUserDefaults.standardUserDefaults()
  var taskNames = [String]()
  var taskPriorities = [Float]()
  
  //this is the function that saves tasks
  func saveTask() {
      println(taskNames)
      println(taskPriorities)
      defaults.setObject(taskNames, forKey: "taskName")
      defaults.setObject(taskPriorities, forKey: "taskPriorities")
      defaults.synchronize()
  }
  
  //this is the function that loads tasks
  func loadTasks() {
      var taskNamesLoad = defaults.dataForKey("taskName")
  
      println(defaults.dataForKey("taskName"))
      println(taskNamesLoad)
  }
  </code></pre>
  
  <p>When I call the function to load the data (after saving some data with the other function of course) the output to the Console is nil and there is no data saved in the user defaults. How can I fix this?</p>