title: Objective-C: How to play a video from the selection of a cell in the UITableView?
body: <p>I want to be able for the user to play a video in the <code>MPMoviePlayerConntroller</code> by selecting the video by tapping a cell in my <code>uitableview</code>so i have this code to list file's into each cell: </p>
  
  <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"];
      if (cell == nil) {
          cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MainCell"];
      }
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      filePathsArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:documentsDirectory  error:nil];
      cell.textLabel.text = [filePathsArray[indexPath.row] lastPathComponent];
  
  
      return cell;
  }
  </code></pre>
  
  <p>This code works successfully but now i need to check what the user has selected so i have this code:</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      NSURL * movieURL = [filePathsArray objectAtIndex:indexPath.row];
      MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: movieURL];
      [[player view] setFrame: [self.view bounds]];  
      [self.view addSubview: [player view]];
      [player play];
  }
  </code></pre>
  
  <p>But this code has a problem with the line <code>NSURL * movieURL = [filePathsArray objectAtIndex:indexPath.row];</code> keeps crashing the simulator.</p>
  
  <p>and i am probably being stupid but i cannot figure out how to fix this.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The problem is that <code>filePathsArray</code> is only returning the name and extension of the video file so for example it will only display <code>testvideo.mp4</code> when i should be getting the full path to that file. Does anybody know how to fix this?</p>
  
  <p>Thanks in advance...</p>