title: How can I send multiple selected items to server?
body: <p>So I collection view that allows users to select multiple categories to feature their photo. When I select a cell the print statements work fine, it prints the name of the cells childValue as expected. When I go to submit the post, it only uploads to the last selected index to the database. </p>
  
  <p>An example of the issue - If I select the categories "prints" and "green" the photo will only post "green" because it was the last selected index. How can I save all of the selections users make and send the post to the selected childValues?</p>
  
  <pre class="lang-swift prettyprint-override"><code>
  
      var selectedCategoryValue = ""
  
      var trend: Trend!
      var style: Style!
  
      // When a cell is selected, the postID will be added to the correct childvalue that is relevent to the post
      func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
          if collectionView == trendCollectionView {
  
  
          switch selectedSegmentIndex {
  
          case 0: self.trend = femaleTrends[indexPath.row]
          print("You selected row \(trend.childValue)")
  
  
          self.selectedCategoryValue = trend.childValue
  
  
          case 1: self.trend = maleTrends[indexPath.row]
              print("You selected row \(trend.childValue)")
              self.selectedCategoryValue = trend.childValue
  
               default: break
  
          }
  
  
          } else {
  
            // Once I figure out how to store multiple selected values, I will complete else statement
              switch selectedSegmentIndex {
  
              case 0: self.style = femaleStyles[indexPath.row]
              case 1: self.style = maleStyles[indexPath.row]
  
                   default: break
  
              }
  
  
          }
  
  
      }
  </code></pre>
  
  <p>Here is the function used when submit is pressed and the photo is uploaded to server</p>
  
  <pre class="lang-swift prettyprint-override"><code>    func uploadPostToCategory(withPostId postId: String) {
  
          let selectedValue = [postId: 1]
              switch trend.gender {
              case .female:
                  // add postId to childValue based on cell selection
                  FEMALE_TRENDS_REF.child(selectedCategoryValue).updateChildValues(selectedValue)
  
              case.male:
                  MALE_TRENDS_REF.child(selectedCategoryValue).updateChildValues(selectedValue)
  
              }
  
  
  
          }
  </code></pre>
  
  <p>handled <code>isSelected</code> inside the collection view cell here.</p>
  
  <pre class="lang-swift prettyprint-override"><code>
     override var isSelected: Bool {
          didSet{
              if self.isSelected {
                  trendCheckmark.isHidden = false
  
              }
              else {
                  trendCheckmark.isHidden = true
  
              }
          }
      }
  </code></pre>