title: How to create a NSImage from a NSData with Swift
body: <p>Sorry to ask such a simple but this is my first program in Swift... I try to create a NSImage from a NSData that contains a JPEG image I loaded from disk (URLs are in an array name choseFiles[]).</p>
  
  <p>The compiler issues an error on the second and I'm stuck:'NSData' is not implicitly convertible to 'Data'; did you mean to use 'as' to explicitly convert? </p>
  
  <p>Thank you</p>
  
  <pre><code>let imageAsNSData = NSData(contentsOf: chosenFiles[0])  // UIKit/UIImage for iOS not MacOS !
  let imageAsNSImage = NSImage(data: imageAsNSData)
  if (imageAsNSImage) {
     // image could be created from NSData
     //
  
  } else {
  
     // image could NOT be created from NSData
     //
  
  }
  </code></pre>
  
  <p>----- EDIT -----</p>
  
  <p>I tried</p>
  
  <p><code>let imageAsNSImage = NSImage(data: imageAsNSData! as Data)
              if (imageAsNSImage != nil) {
  </code>
  which seems to work (at least for the compiler). Am I correct?        </p>