Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 2, 2020 07:15
Show Gist options
  • Save wizard1066/15d954e460bbd192f9d8fc0108b1bf87 to your computer and use it in GitHub Desktop.
Save wizard1066/15d954e460bbd192f9d8fc0108b1bf87 to your computer and use it in GitHub Desktop.
abgwtp6
func dropTarget(info: DropInfo) -> Int {
if info.location.x > UIScreen.main.bounds.width / 2 {
return(1)
} else {
return(0)
}
}
func performDrop(info: DropInfo) -> Bool {
textID = dropTarget(info: info)
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[self.textID] = text
}
}
}
return true
} else {
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment