Skip to content

Instantly share code, notes, and snippets.

@aheze
Last active February 25, 2020 02:54
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/8cde9e3e750d100ca7f076b53e0bc174 to your computer and use it in GitHub Desktop.
Save aheze/8cde9e3e750d100ca7f076b53e0bc174 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])
///First, add a cell to the second collectionview.
baseCollectionViewArray.remove(at: indexPath.item)
baseCollectionView.deleteItems(at: [indexPath])
///Now, remove it from the base collectionview.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment