Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 4, 2020 07:54
Show Gist options
  • Save wizard1066/0810b442a3d9732d9f9a7044178790ba to your computer and use it in GitHub Desktop.
Save wizard1066/0810b442a3d9732d9f9a7044178790ba to your computer and use it in GitHub Desktop.
abgwtp14
func performDrop(info: DropInfo) -> Bool {
textID = dropTarget(info: info)
if textID == nil {
return false
}
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
// we need to subtract 1 cause array starts at zero
self.textColors[self.textID!] = backgrounds[Int(text)! - 1]
if boardFull(textColors: self.textColors, figures: self.rect.count) {
if confirmColours(textColors: self.textColors, figures: self.rect.count) {
timePublisher.send()
}
}
}
}
}
return true
} else {
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment