Search code examples
xcodemacosswiftnsimage

Using image libraries for Mac OS X apps in Swift


The documentation I've found is terribly unclear on this - what I'd like to do is use the provided Xcode image library (catalog?) on a Mac OS X application.

iOS apps get the benefit of being able to use UIKit's UIImage object to quickly reference image files that are loaded into the catalog.

(To wit: UIImage(imageNamed: "Something"))

Since I'm writing a Mac OS app and not an iOS app, I don't get UIKit.

I'd assume that since XCode provides me with the same image library file by default on an OS X app, that I'm somehow intended to make use of it.

How do I reference images inside the library? Ideally I'd be able to do something with NSImage


Solution

  • In this situation, you can use NSImage just like UIImage:

    NSImage(named: "Something")