views:

107

answers:

2

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

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

  return cell;

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

+1  A: 

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

Nicholas Riley
its for an NSMutableArray
AWright4911
You're already iterating through the array, just do something like [theFiles addObject: [s stringByDeletingPathExtension]].
Nicholas Riley
A: 

Actually, for my use, I was able to create a plist programmatically and just not use an extension and it works great! However, anothe rway to do this is:

[string stringByReplacingOccurrencesOfString:@".fileextension" withString:@""];
AWright4911