diff --git a/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift b/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift index cdba5483f..2d12b27b4 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift @@ -3,33 +3,35 @@ // RSCore // // Created by Brent Simmons on 1/28/18. -// Copyright © 2018 Ranchero Software, LLC. All rights reserved. +// Copyright © 2018 Brent Simmons. All rights reserved. // + #if os(macOS) + import AppKit -// Takes a string, not a URL, but writes it as a URL (when possible) and as a String. - +/// Takes a string, not a URL, but writes it as a URL (when possible) and as a String. @objc public final class URLPasteboardWriter: NSObject, NSPasteboardWriting { let urlString: String public init(urlString: String) { - self.urlString = urlString } public class func write(urlString: String, to pasteboard: NSPasteboard) { + write(urlStrings: [urlString], to: pasteboard) + } + public class func write(urlStrings: [String], to pasteboard: NSPasteboard) { pasteboard.clearContents() - let writer = URLPasteboardWriter(urlString: urlString) - pasteboard.writeObjects([writer]) + let writers = urlStrings.map { URLPasteboardWriter(urlString: $0) } + pasteboard.writeObjects(writers) } // MARK: - NSPasteboardWriting public func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] { - if let _ = URL(string: urlString) { return [.URL, .string] } @@ -37,11 +39,11 @@ import AppKit } public func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? { - guard type == .string || type == .URL else { return nil } return urlString } } + #endif