uiTableView select the previous selected row?
<p>I have a problem with  <code>didDeselectRowAtIndexPath</code> delegate function.
as when i select for the first time, <code>didDeselectRowAtIndexPath</code> isn't called.</p>

<p>but when i select another cell , <code>didDeselectRowAtIndexPath</code> is called but with index path for the previous selection.</p>

<p>let's take an example:</p>

<ol>
<li>i've selected row at index 5. so nothing will be happened.</li>
<li>i've selected row at index 12, then <code>didDeselectRowAtIndexPath</code> will be called with indexPath.row = 5.</li>
</ol>

<p>I don't why this happened , here is my code : thanks</p>

<pre><code>class testUICollectionView: UIViewController ,UITableViewDelegate,UITableViewDataSource {

    let tableItems :NSMutableArray = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5",
        "Item 6", "Item 7", "Item 8", "Item 9", "Item 10", "Item 11",
        "Item 12", "Item 13", "Item 14", "Item 15","Item 12", "Item 13", "Item 14", "Item 15","Item 12", "Item 13", "Item 14", "Item 15"]

    var tableView:UITableView!;

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.blueColor();

        tableView = UITableView();
        tableView.frame = self.view.frame;
        tableView.registerClass(TableViewCell.self, forCellReuseIdentifier: "Cell");
        tableView.dataSource = self;
        tableView.delegate = self;
        self.view.addSubview(tableView)
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
        // Return the number of rows in the section.
        return tableItems.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as!  TableViewCell
        cell.setTextLabel(tableItems[indexPath.row] as! String);

        return cell
    }

    func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
        print("inexPath.row : " + String(indexPath.row));
    }
}


////////////////////////// table view cell
class TableViewCell:UITableViewCell{

    var label:UILabel!;

    func setTextLabel(new_text:String){

        if (label == nil){
            label = UILabel();
            label.frame = self.contentView.frame;
            label.textColor = UIColor.whiteColor();
            label.backgroundColor = UIColor.whiteColor();
            label.textColor = UIColor.blackColor();
            self.contentView.addSubview(label);
        }

        label.text = new_text;
    }
}
</code></pre>