Q:

How to maintain a reference to a tableview cell?

I've built a basic media player app.
I have a tableView in which I list Podcasts.
Within the row item, I list the podcast title.
I also use the detailTextLabel to list a countdown of the current playtime.
Everything works fine except when I scroll the tableView the cell gets reloaded and I can no longer update the time.
How can I keep a reference to the cell so I can update the cell text even after scrolling?
Here are the pertinent pieces of code....
var myCell = UITableViewCell()

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell:UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cell")

    .... cell code

    return cell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    myMP.nowPlayingItem = qryPodcasts.items![indexPath.row]
    if myMP.playbackState != MPMusicPlaybackState.Playing {
       myMP.play()
    }

    // Grab a reference to the selected item
    // for displaying elapsed time
    myCell = tableView.cellForRowAtIndexPath(indexPath)!
}

func startTimer(){
    myTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: #selector(View_Podcast_List.updateTimer), userInfo: nil, repeats: true)
}
func stoptimer(){
    myTimer.invalidate()
}
func updateTimer(){
    let nowPlayingItemDuration =  myMP.nowPlayingItem?.valueForProperty(MPMediaItemPropertyPlaybackDuration) as! Double
    let remainingTime = nowPlayingItemDuration - myMP.currentPlaybackTime ;

    myCell.detailTextLabel?.text = CommonFuncs.secondsToTime(Int(remainingTime))
}

A:

There are 2 ways you can proceed on this:
1st one is tag approach:
In your cellForRow give tag to cell:
MyCell.tag = indexPath.row

When you select an item in didSelect store the indexPath.row in a property.
Now in updateTimer method extract the cell using viewWithTag(indexPath.row) which will give you your cell and then update the timer on that cell.
2nd Approach:
In didSelect store the indexPath.row in property when selected. Then in cellForRow if indexPath.row is equal to the select property from didSelect then call the method updateTimer which actually returns the text (you may need to update your method in this case)
if(indexPath.row == selectRow) {
    myCell.detailTextLabel?.text = self.updateTimer()
}

