Created
May 25, 2020 12:28
-
-
Save pilky/c3d9e7223c797fd4f219eb1d0231e0c1 to your computer and use it in GitHub Desktop.
NSFilePromiseProvider that supports additional types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExtendableFilePromiseProvider: NSFilePromiseProvider { | |
var additionalItems: [NSPasteboard.PasteboardType: Any] = [:] | |
override func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] { | |
var types = super.writableTypes(for: pasteboard) | |
if self.additionalItems.count > 0 { | |
types.append(contentsOf: self.additionalItems.keys) | |
} | |
return types | |
} | |
override func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? { | |
if let item = self.additionalItems[type] { | |
return item | |
} | |
return super.pasteboardPropertyList(forType: type) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment