title: How to correctly insert UILabels into each tebleview cell
body: <p>I am having a problem creating UILabels to insert into my tableview cells. They insert fine and display fine, the problem comes in when I go to scroll. The ordering of the row's goes haywire and looses it's initial order. For instance, at the beginning, the idLabel's cell text, goes from 0 > 14, in sequential order. After scrolling down and back up, the order could be anything, 5, 0, 10, 3 etc.</p>
  
  <p>Any ideas on why this is happening? I am presuming my attempts to update the label's after cell creation is wrong.</p>
  
  <pre><code>var idArr: NSMutableArray!
  
  // In init function
  self.idArr = NSMutableArray()
  for ind in 0...14 {
      self.idArr[ind] = ind
  }
  
  // Create the tableview cells
  internal func tableView( tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath ) -&gt; UITableViewCell {
      if cell == nil {
          let id = self.idArr[indexPath.row] as Int
          cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cell" )
  
          // Id
          let idLabel: UILabel = UILabel( frame: CGRectZero )
          idLabel.text = String( id )
          idLabel.textColor = UIColor.blackColor()
          idLabel.tag = indexPath.row
          idLabel.sizeToFit()
          idLabel.layer.anchorPoint = CGPointMake( 0, 0 )
          idLabel.layer.position.x = 15
          idLabel.layer.position.y = 10
          idLabel.textAlignment = NSTextAlignment.Center
          cell?.addSubview( idLabel )
      }
  
      // Update any labels text string
      for obj: AnyObject in cell!.subviews {
          if var view = obj as? UILabel {
              if view.isKindOfClass( UILabel ) {
                  if view.tag == indexPath.row {
                      view.text = String( id )
                  }
              }
          }
      }
  
      // Return the cell
      return cell!
  }
  </code></pre>
  
  <p>Thanks for any assistance, I can't see the wood for the trees anymore.</p>