title: UICollectionView custom button actions in Swift 3
body: <p>I have used UICollectionView and I am populating it with results from API. There is a ID, Image, Name, Description and Liked true or false coming in API.
  I have implemented all these things and now all the results loads inside this collection view.</p>
  
  <pre><code>    extension VCResCourses : UICollectionViewDelegate {
  
  }
  
  extension VCResCourses: UICollectionViewDelegateFlowLayout {
      func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize
      {
          let length = (UIScreen.main.bounds.width - 16)
          return CGSize(width: length, height: 135);
      }
  }
  
  extension VCResCourses : UICollectionViewDataSource {
      func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
          return 1
      }
  
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return dataSources.numbeOfRowsInEachGroup(section)
      }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let currentCell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier,for:indexPath) as! CVCResCourse
  
      let doCourses: [DOCourses] = dataSources.total()
      let doCourse = doCourses[indexPath.row]
  
      let courseId = doCourse.Id!
      var courseName = doCourse.Name!
      let courseAddress = doCourse.Address!
      let courseImage = doCourse.Image!
      let courseWish = doCourse.Wish!
  
      courseName = courseName.replacingOccurrences(of: "\t", with: "", options: .literal, range: nil)
  
      currentCell.imageView.kf.setImage(with: URL(string: courseImage))
      currentCell.textPrimary.text = courseName.capitalized
      currentCell.textSecondary.text = courseAddress.capitalized
      currentCell.buttonOpen.addTarget(...)
      currentCell.buttonFav.addTarget(...)
  
      return currentCell
      }
  }
  </code></pre>
  
  <p>What I am trying now is there are two button on each CELL one opens details of the record and other set favourite to true or false.</p>
  
  <p>Now I need to get id of the current record and toggle its favourite state to true or false or open the detail page using the id. I am not able to add action for buttons and perform the favourite or open detail action using ID.</p>
  
  <p>In android I have done this by adding clickListener inside CustomBaseAdapter which perform actions for each row or record of the data. I need to do the same in iOS as well but no luck yet</p>
  
  <p>I am new to iOS development please help</p>