title: Swift: How to change NSImage image source?
body: <p>I'm a newbee with XCode and Swift. Trying to simply set an image in my view in an OS X application. The image should be loaded from the web, but I think that doesn't matter.</p>
  
  <p>I created a new Cocoa App, have a list view which works. In the XIB for the list row I have placed an "Image View" element and with this I can display a static image in each row.</p>
  
  <p>Now I want to change the image URL when the row loads. I dragged the line from the image to my controller class, which added the <code>@IBOutlet</code> to the code.</p>
  
  <p>This is my code of the controller class:</p>
  
  <pre><code>import Cocoa
  
  class ListRowViewController: NSViewController {
  
      @IBOutlet weak var rowImage: NSImageView!
  
      override var nibName: String? {
          return "ListRowViewController"
      }
  
      override func loadView() {
          super.loadView()
  
          var url = NSURL(fileURLWithPath: "http://example.com/some-image.png")
  
          var image = NSImage(byReferencingURL: url!)
  
          self.rowImage.image(image)
      }
  
  }
  </code></pre>
  
  <p>Now the very <strike>funny</strike> frustrating error message from the last statement (<code>self.rowImage.image(image)</code>) is</p>
  
  <blockquote>
    <p>Cannot convert the expression's type 'NSImage' to type 'NSImage?'.</p>
  </blockquote>
  
  <p>OK. What does that mean and how do I fix it? Is that somehow related to optionals? I experimented with <code>?</code>'s and <code>!</code>'s but just can't figure out what XCode expects from me.</p>