Last active
November 23, 2017 10:55
-
-
Save icanswiftabit/d7e5f811b667307fedbbced508025f43 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
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