> On Jul 17, 2017, at 8:26 AM, Jon Shier via swift-users 
> <swift-users@swift.org> wrote:
> 
>       Like Notification.Name, I believe those types are supposed to help you 
> namespace your string constants when you access them. I’d recommend using a 
> code gen tool to generate them from your image assets, like:
> 
> extension NSImage.Name {
>       static let customImage = NSImage.Name(rawValue: “customImage”)
> }
> 
> Which can then be used like: NSImage(named: .customImage). That’s the 
> ultimate use goal. It does make the old code awkward and a pain to migrate 
> though.

Yeah, this is the intended use pattern for these namespaced constant. You don't 
need the `rawValue:` label, though:

extension NSImage.Name {
  static let myImage = Name("myImage")
}

-Joe
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to