title: Using NSTask in swift to execute a terminal command
body: <p>Hi i'm trying to make a simple program with swift to execute this command that adds a white space in Dock:</p>
  
  <p><code>defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'; killall Dock</code></p>
  
  <p>this is the code i use:</p>
  
  <pre><code>    let task = NSTask()
      task.launchPath = "/usr/bin/defaults"
      task.arguments = ["write","com.apple.dock","persistent-apps","-array-add","'{\"tile-type\"=\"spacer-tile\";}';","killall Dock"]
      let pipe = NSPipe()
      task.standardOutput = pipe
      task.standardError = pipe
      task.launch()
      task.waitUntilExit()
      let data = pipe.fileHandleForReading.readDataToEndOfFile()
      let output: String = NSString(data: data, encoding: NSUTF8StringEncoding) as! String
      print(output)
  </code></pre>
  
  <p>I get no errors but nothing happens. Can someone help me please?</p>