title: Checkbox in UICollectionViewCell
body: <p>Hello this question has been raised more than once here, but I can not find help
  My problem is when adding Checkbox in UICollectionViewCell
  Well, I've tried a lot of ways but to no avail
  This image shows what is located in UICollectionViewCell </p>
  
  <p><img src="https://i.stack.imgur.com/JvUfI.png" alt="enter image description here"></p>
  
  <p>Well, when I click inside the Checkbox, it is his choice, but the rest of the foods are also selected, which I want to do, click inside the Checkbox when it selects box in cell and is updated the UICollectionView</p>
  
  <p><strong>Custom Checkbox code</strong> </p>
  
  <pre><code>var isCheckedGlobal = Bool() // !! Global Variable // You might need to change '= Bool()' to '= false' or '= true'
  
  class CheckBox: UIButton {
  
      //images
  
      let checkedImage = UIImage(named: "checked") as UIImage?
      let unCheckedImage = UIImage(named: "unchecked")as UIImage?
  
      //bool propety
      var isChecked:Bool = false{
          didSet{
              if isChecked == true{
                  self.setImage(checkedImage, forState: .Normal)
              }else{
                  self.setImage(unCheckedImage, forState: .Normal)
              }
          }
      }
  
      override func awakeFromNib() {
          self.addTarget(self, action: "buttonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
          self.isChecked = false
      }
  
      func buttonClicked(sender:UIButton) {
          if(sender == self){
              if isChecked == true{
                  isChecked = false
                  isCheckedGlobal = false // !! Set variable's value
              }else{
                  isChecked = true
                  isCheckedGlobal = true // !! Set variable's value
              }
          }
      }
  
  }
  </code></pre>
  
  <p><strong>cellForItemAtIndexPath code</strong></p>
  
  <pre><code>func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
          let cell = collectionView.dequeueReusableCellWithReuseIdentifier("ordercell", forIndexPath: indexPath) as! SuperStarOrdersCollectionViewCell
  
          if isCheckedGlobal == true{
              println("Checked Cell \(indexPath.row)")
          }
          else{    
              println("unChecked Cell \(indexPath.row)")
          }
          return cell   
      }
  </code></pre>