SHARE
TWEET

Untitled

a guest Mar 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  2.        
  3.         if let datasource = flavoursDataSource {
  4.            
  5.             let cell = collectionView.cellForItem(at: indexPath) as! TasteCollectionViewCell
  6.            
  7.             let flavourGroup = datasource.priorityFlavourGroups[indexPath.section]
  8.             let flavour = flavourGroup.groupFlavours[indexPath.row]
  9.            
  10.             let selectedFlavours = selectedGroups.flatMap({$0.groupFlavours})
  11.            
  12.             if selectedFlavours.first(where: ({ $0.flavourName == flavour.flavourName})) != nil {
  13.                 selectedGroups.first(where: ({$0.groupName == flavourGroup.groupName}))?.groupFlavours.removeAll(where: {$0.flavourName == flavour.flavourName})
  14.                 cell.deSelectCell()
  15.             } else {
  16.                 selectedGroups.first(where: ({$0.groupName == flavourGroup.groupName}))?.groupFlavours.insert(flavour, at: 0)
  17.                 cell.selectCell()
  18.             }
  19.             tableView.reloadData()
  20.         }
  21.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top