I did it differently to be able to run on iOS or macOS, testing for OS type. Xcode 15.0 and 15.3.
@eskimo: is it useless ?
#if os(macOS)
typealias XPasteboard = NSPasteboard
#else
typealias XPasteboard = UIPasteboard
#endif
extension XPasteboard {
func copyString(_ text: String) {
#if os(macOS)
self.clearContents()
self.setString(text, forType: .string)
#else
self.string = text
#endif
}
func copyImage(_ image: Data) {
#if os(macOS)
self.clearContents()
self.setData(image, forType: .png)
#else
self.image = UIImage(data: image)
#endif
}
}
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: