title: Cell's progress bar duplicates on other cells
body: <p>I have a cell reuse problem.</p>
  
  <p>All my cells are identical, there is only one section. Cells include a label, button and progress bar.</p>
  
  <p>The button triggers a sound (it's a simple "play" button). When the AVAudioPlayers delegate method is called, <code>audioPlayerDidFinishPlaying:</code>, I nullify the <code>NSTimer</code> that updates the progress bar, hide the progress bar, and nullify the audio player as well.</p>
  
  <p>All this happens in my cell's class which inherites from <code>UITableViewCell</code>.</p>
  
  <p>Everything works like it should, except for one thing : </p>
  
  <p><strong>Scrolling while playing a sound shows the same progress bar on the new cells.</strong></p>
  
  <p>So if I tap, say, the second cell, the second next cell being shown when scrolling will have a progress bar moving forward (and stop+hide when the sound finishes).</p>
  
  <p>I'll show you my custom cell complete class, I hope this will help. I don't really know how to fix this. I tried if-statements in the <code>cellForRow:</code> but without any real success.</p>
  
  <pre><code>@implementation SoundItemTableViewCell
  
  - (void)awakeFromNib {
      // Initialization code
      self.progressBar.hidden = YES;
  }
  
  - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
      [super setSelected:selected animated:animated];
  
      // Configure the view for the selected state
  }
  
  - (IBAction)playSound:(id)sender {
  
      [self.progressBar setProgress:0];
      self.progressBar.hidden = NO;
  
      NSString *filename = self.fileName;
      [self playSoundWithURL:[NSURL URLWithString:filename]];
  }
  
  - (void)playSoundWithURL:(NSURL*)url{
  
  
      NSError *error;
      if (self.audioPlayer){
  
          if(self.audioPlayer.playing){
              [self.audioPlayer stop];
          }
      }
  
      self.audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&amp;error];
      self.audioPlayer.delegate = self;
      self.tmrProgress = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateElapsedTime) userInfo:nil repeats:YES];
  
      [self.audioPlayer prepareToPlay];
      [self.audioPlayer play];
      NSLog(@"Starting sound play with item : %@",url);
  
  }
  
  - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{
  
      [self.progressBar setProgress:0 animated:YES];
      self.progressBar.hidden = YES;
      //self.progressBar = nil;
      [self.tmrProgress invalidate];
      self.tmrProgress = nil;
      player = nil;
      self.audioPlayer = nil;
      NSLog(@"Audio Finish");
  }
  
  
  - (void)updateElapsedTime{
      if (self.audioPlayer) {
          NSLog(@"Updating progress");
          [self.progressBar setProgress:[self.audioPlayer currentTime] / [self.audioPlayer duration]];
      }
  }
  </code></pre>
  
  <p>The tableview. <code>pushList</code> is an array containing file URLs</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
      static NSString *identifier = @"SoundItemTableViewCell";
      SoundItemTableViewCell *cell = [self.tbPushList dequeueReusableCellWithIdentifier:identifier];
  
      if (cell == nil) {
          cell = [[SoundItemTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
      }
      cell.fileName    = [pushList objectAtIndex:indexPath.row];
      cell.lbName.text = [[[pushList objectAtIndex:indexPath.row] lastPathComponent] stringByDeletingPathExtension];
      return cell;
  
  }
  </code></pre>
  
  <p>The best I could achieve was to hide the progress bar when it goes out of view, and therefore no other progress bar would show either, but rescrolling to my playing cell would then have a sound playing with no progress bar, which is unsatisfactory/bad UX behaviour.</p>