title: how to use writeToFile to save image in document directory?
body: <pre><code>// directoryPath is a URL from another VC
  @IBAction func saveButtonTapped(sender: AnyObject) {
              let directoryPath           =  NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
              let urlString : NSURL       = directoryPath.URLByAppendingPathComponent("Image1.png")
              print("Image path : \(urlString)")
              if !NSFileManager.defaultManager().fileExistsAtPath(directoryPath.absoluteString) {
                  UIImageJPEGRepresentation(self.image, 1.0)!.writeToFile(urlString.absoluteString, atomically: true)
                  displayImageAdded.text  = "Image Added Successfully"
              } else {
                  displayImageAdded.text  = "Image Not Added"
                  print("image \(image))")
              }
          }
  </code></pre>
  
  <p>I am not getting any error but the Image is not getting saved in the document.</p>