小编典典

Objective-C:从路径字符串中提取文件名

all

当我有NSString/Users/user/Projects/thefile.extthefile用Objective-C方法提取时。

最简单的方法是什么?


阅读 162

收藏
2022-05-19

共1个答案

小编典典

取自NSString
参考
,您可以使用:

NSString *theFileName = [[string lastPathComponent] stringByDeletingPathExtension];

lastPathComponent调用将返回,thefile.ext并且stringByDeletingPathExtension将从末尾删除扩展后缀。

2022-05-19