title: Swift - Adding a checkbox to every cell in the tableView
body: <p>I've already made a table view which allows the user to add tasks to the table view, but now I need to add a checkbox in front of each task, so that the user can select which tasks she/he wants to send to an other viewController.</p>
  
  <p>After I googled it, I realized that there is no checkBox or radioButton in swift, I should create my own "boxChecked.png" and "boxUnchecked.png", </p>
  
  <p>Here is a piece of my code which gives me an error:</p>
  
  <pre><code>if (selectedIndex == indexPath) {
      cell.radioButton?.setImage(UIImage(named: "boxChecked"),forState:UIControlState.Normal)
  } else {
      cell.radioButton?.setImage(UIImage(named: "boxUnchecked"),forState:UIControlState.Normal)
  }
  </code></pre>
  
  <p>and the error it gives me is:</p>
  
  <pre><code>'UITableViewCell?' does not have a member named 'radiobutton'
  </code></pre>
  
  <p>even though I tried creating a class named TableViewCell which is a subclass of UITableViewCell, and declared the variable <em>radioButton</em> in it like:</p>
  
  <pre><code> @IBOutlet weak var radioButton: UIButton!
  </code></pre>
  
  <p>but it still didn't work.</p>
  
  <p>Here is the code of <em>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)</em>:</p>
  
  <pre><code> func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell
      {
  
          let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cell")
  
  
  
  
          if (selectedIndex == indexPath) {
              cell.radioButton?.setImage(UIImage(named: "boxChecked"),forState:UIControlState.Normal)
          } else {
              cell.radioButton?.setImage(UIImage(named: "boxUnchecked"),forState:UIControlState.Normal)
          }
  
  
  
  
  
  
          cell.textLabel?.textAlignment = .Right
          cell.detailTextLabel?.textAlignment = .Left
  
        cell.textLabel?.text = taskMgr.tasks[indexPath.row].name
  
          cell.detailTextLabel?.text = taskMgr.tasks[indexPath.row].score
  
  
  
  
  
  
  
          return cell
  
          //let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Default")
         // cell.textLabel?.text = taskMgr.tasks[indexPath.row].name
         // cell.detailTextLabel?.text = taskMgr.tasks[indexPath.row].desc
         //return cell
  
      }
  </code></pre>