I am implementing an audio player in my app. and I have a UITableView in which i show my list of audio tracks.
the list of audio is added into an array with
fileArray = [[NSMutableArray alloc] initWithObjects:
[[NSBundle mainBundle] pathForResource:@"A Million Years" ofType:@"mp3"],
[[NSBundle mainBundle] pathForResource:@"2 Million Years" ofType:@"mp3"],...
and in my cellForRowAtIndexPath I am doing
cell.textLabel.text = [[NSString stringWithFormat:@"%@", [self.fileArray objectAtIndex:indexPath.row]] stringByDeletingPathExtension];
but the problem is that it still shows me an entire extension “/Users/….”. i only want the file name (“A Million Years”, “2 Million Years”) to be shown.
What am I doing wrong? I have been looking around for an answer but was never able to get it (perhaps due to wrong phrasing)
Thanks very much everybody. 🙂
You should use
lastPathComponentif you want the last part of it. So: