开发者

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 exampl开发者_开发百科e "Xylophone.m4r" I want to remove the .m4r.


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


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:@""];


Just have to delete path extension component:

cell.textLabel.text = [[theFiles objectAtIndex:indexPath.row] stringByDeletingPathExtension];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜