Skip to content

Instantly share code, notes, and snippets.

@sascha
Created May 4, 2015 12:15
Show Gist options
  • Save sascha/dac79652aa5962b36d08 to your computer and use it in GitHub Desktop.
Save sascha/dac79652aa5962b36d08 to your computer and use it in GitHub Desktop.
extension NSImage {
class func imageNamed(name: String, inBundle bundle: NSBundle?) -> NSImage? {
var image = NSImage(named: name)
if let image = image {
return image
}
image = bundle?.imageForResource(name)
if let image = image {
image.setName(name)
return image
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment