title: Select ALL TableView Rows Programmatically Using selectRowAtIndexPath
body: <p>I'm trying to programmatically select all rows in my tableview using the following code:</p>
  
  <pre><code> func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      let cell:myTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell") as! myTableViewCell
  
       cell.accessoryType = .None
  
      if allJobsSelected {
  
          let bgColorView = UIView()
          bgColorView.backgroundColor = UIColor(red: 250/255, green: 182/255, blue: 17/255, alpha: 1)
          cell.contentView.backgroundColor = UIColor(red: 250/255, green: 182/255, blue: 17/255, alpha: 1)
          cell.selectedBackgroundView = bgColorView
          cell.accessoryType = .Checkmark
          cell.highlighted = false
  
          cell.selected = true
          //  cell.accessoryType = .Checkmark
          self.tableView.selectRowAtIndexPath(indexPath, animated: true, scrollPosition: UITableViewScrollPosition.None)
          self.tableView(self.tableView, didSelectRowAtIndexPath: indexPath)
  
      }
  
      var job: Jobs!
  
      job = jobs[UInt(indexPath.row)] as! Jobs
  
      cell.reports2JobTitle.text = job.jobTitle
  
  
      return cell
  }
  
   func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
      self.tableView.allowsMultipleSelection = true
  
      if let cell:myTableViewCell = tableView.cellForRowAtIndexPath(indexPath) as? myTableViewCell {
  
          let bgColorView = UIView()
          bgColorView.backgroundColor = UIColor(red: 250/255, green: 182/255, blue: 17/255, alpha: 1)
          cell.contentView.backgroundColor = UIColor(red: 250/255, green: 182/255, blue: 17/255, alpha: 1)
          cell.selectedBackgroundView = bgColorView
          cell.accessoryType = .Checkmark
          cell.highlighted = false
          self.tableView.selectRowAtIndexPath(indexPath, animated: true, scrollPosition: UITableViewScrollPosition.Bottom)
  
      }
  
  
  }
  </code></pre>
  
  <p>My issue is that only the rows that have been dequeued are added to my table's data model when I segue to the next viewcontroller. In order to add all the rows to my table's data model I have to manually scroll through the whole table. How can I change this so all the selected rows are added to my table's data model without having to scroll through the whole table? </p>
  
  <p>What I cannot understand is that after all my rows are selected I then loop through my indexPaths as follows but not all of the indexPaths are added unless I first scroll through the entire table.</p>
  
  <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
  
      if (segue.identifier == "reportsDisplay") {
          let controller = segue.destinationViewController as! ReportsDisplayViewController
  
          var selectedJob : Jobs!
  
          if let indexPaths = tableView.indexPathsForSelectedRows {
  
  
              for i in 0 ..&lt; indexPaths.count {
  
                  let thisPath = indexPaths[i]
  
  
  
                  selectedJob = jobs[UInt(thisPath.row)] as! Jobs
  
  
  
                  let jobTitle = selectedJob.jobTitle
                  let id = selectedJob.identifier
  
  
  
                  jobsToReport.append(jobTitle)
                  jobsID.append(id)
  
  
  
              }
  
  
          }
  
          controller.reportedJobs = jobsToReport
          controller.idOfJobs = jobsID
  
      }
  
  
  }
  </code></pre>