【发布时间】:2011-11-05 14:07:19
【问题描述】:
我知道你可以使用 NSBundle:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"rtf"];
获取文件的文件路径,但是如何使用 NSBundle 以编程方式从文件路径中获取文件名和扩展名(单独)。
例如,我可能有:/Users/theuser/Documents/yourdocument.txt
很明显文件是'yourdocument',扩展名是'txt'
但我需要从文件路径中获取文件名和扩展名以用作 NSString。
非常感谢您的帮助!
【问题讨论】:
标签: cocoa nsstring filenames filepath nsbundle