Created
April 2, 2020 07:09
-
-
Save wizard1066/54370b55f7db8ac76e3db485843e13f6 to your computer and use it in GitHub Desktop.
abgwtp4
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
struct TheDropDelegate: DropDelegate { | |
@Binding var textText:String | |
func validateDrop(info: DropInfo) -> Bool { | |
return info.hasItemsConforming(to: ["public.utf8-plain-text"]) | |
} | |
func dropEntered(info: DropInfo) { | |
print("drop entered") | |
} | |
func performDrop(info: DropInfo) -> Bool { | |
if let item = info.itemProviders(for: "public.utf8-plain-text").first { | |
item.loadItem(forTypeIdentifier: "public.utf8-plain-text", options: nil) { (urlData, error) in | |
DispatchQueue.main.async { | |
if let urlData = urlData as? Data { | |
let text = String(decoding: urlData, as: UTF8.self) | |
self.textText = text | |
} | |
} | |
} | |
return true | |
} else { | |
return false | |
} | |
} | |
func dropUpdated(info: DropInfo) -> DropProposal? { | |
print("drop Updated") | |
return nil | |
} | |
func dropExited(info: DropInfo) { | |
print("dropExited") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment