I currently get the following error:
Instance method 'loadObject(ofClass:completionHandler:)' requires that 'NSItemProvider' conform to '_ObjectiveCBridgeable'
with this code:
.onDrop(of: ["public.text"], isTargeted: nil) { providers, location in
guard let provider = providers.first else { return false }
provider.loadObject(ofClass: NSItemProvider.self) { item, error in
guard error == nil, let item = item else { return }
if let curTool = item as? Tools, let dropURL = item as? URL {
handleDrop(with: (curTool, dropURL))
}
}
return true
}
func handleDrop(with dropData: (Tools, URL)) {
let (curTool, curURL) = dropData
}
Here is the matching on drag (curTool is a simple enum) :
.onDrag {
let curTool = Tools.circle
let curURL = URL(string: "https://example.com")!
let itemProvider = NSItemProvider(object: NSString(string: "Dummy data"))
itemProvider.registerObject(String(describing: curTool) as NSItemProviderWriting, visibility: .all)
itemProvider.registerObject(curURL as NSItemProviderWriting, visibility: .all)
return itemProvider
}