title: How to write an image to a path in swift 3.0
body: <p>I'm using core data to store a url to an image that was taken from the imagepicker.</p>
  
  <p>So far I have the following: </p>
  
  <pre><code>    let tempImage = info[UIImagePickerControllerOriginalImage] as? UIImage
  
      let image = UIImageJPEGRepresentation(tempImage!, 0.2)
  
      let path = try! FileManager.default.url(for: FileManager.SearchPathDirectory.documentDirectory, in: FileManager.SearchPathDomainMask.userDomainMask, appropriateFor: nil, create: false)
      let imageName = UUID().uuidString + ".jpg"
  
      let aPath = path.path
  
      let imagePath = (aPath as NSString).appendingPathComponent(imageName)
  </code></pre>
  
  <p>The result is now I have a path as a string to save in core data. 
  But how do I write the image to the path?
  I was trying to use:</p>
  
  <pre><code>   let result = image!.writeToFile(path, atomically: true)
  </code></pre>
  
  <p>But i get an error saying value of type data has no member writeToFile. Is there another way to do it in swift 3.0?</p>
  
  <p>Thanks for your help.</p>