9

NSMutableArray表のセルにあるテキストからファイル拡張子を削除したいと考えています。

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;

これは、たとえば「Xylophone.m4r」をリストします.m4rを削除したいです。

4

3 に答える 3

38

-[NSString stringByDeletingPathExtension](NSPathUtilities.h で)試してください。

于 2009-11-16T06:43:50.237 に答える
3

実際、私の使用では、拡張機能を使用せずにプログラムで plist を作成することができ、うまく機能しました! ただし、これを行う別の方法は次のとおりです。

[string stringByReplacingOccurrencesOfString:@".fileextension" withString:@""];
于 2010-01-08T02:36:30.583 に答える
0

パス拡張コンポーネントを削除するだけです:

cell.textLabel.text = [[theFiles objectAtIndex:indexPath.row] stringByDeletingPathExtension];
于 2015-05-26T12:24:09.730 に答える