Search code examples
macosswiftnsimage

initializing NSImage in swift


Trying to initializing NSImage object.

var image = NSImage("Images/pause_work_normal.png")

But get an error: ambiguous reference to member NSImage.init


Solution

  • Try this:

      var image:NSImage!
      image = NSImage(named:"Images/pause_work_normal.png")
    

    Or the short way

    var image = NSImage(named:"Images/pause_work_normal.png")