Search code examples
nsstringnsmutablearraytrim

Trim file extension UITableView


I want to trim the file extension from text I have an NSMutableArray in table cells.

NSMutableArray *theFiles = [NSMutableArray new];
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:@"/Test"];
for (NSString *s in fileList){
    [theFiles addObject:fileList];
}
cell.textLabel.text = theFiles[indexPath.row];
return cell;

This lists for example "Xylophone.m4r" I want to remove the .m4r.


Solution

  • Try -[NSString stringByDeletingPathExtension] (in NSPathUtilities.h).