Skip to content

Instantly share code, notes, and snippets.

@danielctull
Last active June 6, 2018 16:18
Show Gist options
  • Save danielctull/333d845ed4d8c18b5ed4f65e3353cd24 to your computer and use it in GitHub Desktop.
Save danielctull/333d845ed4d8c18b5ed4f65e3353cd24 to your computer and use it in GitHub Desktop.
The following would error on 10.13, because NSImage.Name was a struct so the static property defined here was not available on String, with line 10 causing an error. With the macOS 10.14 SDK, NSImage.Name is a typealias to String, so additions to NSImage.Name via extensions are now actually extensions on String. πŸ€”
import Cocoa
extension NSImage.Name {
static var amazing: NSImage.Name {
return NSImage.Name("AmazingImage!")
}
}
let imageName = String.amazing
print(imageName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment