I’m displaying contents of the tmp directory in a UITableView, but cannot get the filepath for each cell.
When the cell is pressed, my app should play the file with MPMoviePlayer but is not.
This is what I have so far:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *tmpDirectory = NSTemporaryDirectory();
fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:tmpDirectory error:nil]; //nsarray
NSString *movieURL = [fileList objectAtIndex:indexPath.row];
NSURL *url = [NSURL URLWithString:movieURL];
_moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentModalViewController:_moviePlayerViewController animated:YES];
}
NSlog gives me the name of the video, but not the path. I feel like I’m over thinking this from lack of sleep.
When you use this:
It’ll return only the file name inside the temporary directory,
So use this: