Last active
January 2, 2018 13:15
-
-
Save paul1893/7b3511b82a66644044fea7f19d5bfc38 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) { | |
// 1) Première possibilité | |
let progress = session.loadObjects(ofClass: UIImage.self) { imageItems in | |
let images = imageItems as! [UIImage] | |
self.selectedImageView.image = images.first | |
} | |
// 2) Seconde possibilité | |
for item in session.items { | |
item.itemProvider.loadObject(ofClass: UIImage.self) { (object, error) in | |
if object != nil { | |
// Je suis sur un background thread c’est donc ma responsabilité de revenir au main thread | |
DispatchQueue.main.async { | |
self.imageView.image = (object as! UIImage) | |
} | |
} else { | |
// Handle the error | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment