Skip to content

Instantly share code, notes, and snippets.

@aheze
Last active July 26, 2020 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aheze/d3b74cb3eb4fb9da0331700d534ec38a to your computer and use it in GitHub Desktop.
Save aheze/d3b74cb3eb4fb9da0331700d534ec38a to your computer and use it in GitHub Desktop.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if collectionView == baseCollectionView {
let alphabetLetter = baseCollectionViewArray[indexPath.item]
secondCollectionViewArray.append(alphabetLetter)
let newIndexPath = IndexPath(item: secondCollectionViewArray.count - 1, section: 0)
secondCollectionView.insertItems(at: [newIndexPath])
baseCollectionViewArray.remove(at: indexPath.item)
baseCollectionView.deleteItems(at: [indexPath])
} else {
///ADD THIS STUFF
let alphabetLetter = secondCollectionViewArray[indexPath.item]
baseCollectionViewArray.insert(alphabetLetter, at: 0)
let newIndexPath = IndexPath(item: 0, section: 0)
///I guess we'll put it at the front for now?
baseCollectionView.insertItems(at: [newIndexPath])
secondCollectionViewArray.remove(at: indexPath.item)
secondCollectionView.deleteItems(at: [indexPath])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment