I'm learning to code in swift. I'm trying to load an image onto an image cell located within an image well.I'm using the following code
import Cocoa
class ViewController: NSViewController {
@IBOutlet weak var well: NSImageCell!
@IBAction func clickme(_ sender: Any) {
let image = NSImage(byReferencing:NSURL(string: "http://imgsv.imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-140mmf_35-56g_ed_vr/img/sample/sample1_l.jpg")! as URL)
well.image=image;
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
No exception is thrown nor any image is loaded. What I'm I doing wrong?