Skip to content

Instantly share code, notes, and snippets.

@icanswiftabit
Last active November 23, 2017 10:55
Show Gist options
  • Save icanswiftabit/d7e5f811b667307fedbbced508025f43 to your computer and use it in GitHub Desktop.
Save icanswiftabit/d7e5f811b667307fedbbced508025f43 to your computer and use it in GitHub Desktop.
coordinator.session.loadObjects(ofClass: Cat.self) { cats in
DispatchQueue.main.async {
if coordinator.session.localDragSession != nil, let previousIndex = self.viewModel.cats.index(where: { $0.name == cat.name }) {
//Local drag session
self.viewModel.cats.swapAt(previousIndex, destinationIndexPath.row)
} else {
// External drag session
self.viewModel.cats.insert(cat, at: destinationIndexPath.row)
}
collectionView.reloadSections(destinationIndexPath.section)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment