我是 iphone 新手。我怀疑我的音频文件的路径位于资源文件夹的目录中,该路径是
/Users/Chary/Library/Application Support/iPhone Simulator/5.0/Applications/B02404E5-52DC-49B6-8DBB-C9946E4331AF/BiblePlayer.app/raj/1.mp3
我的问题是如何从整个路径中检索字符串“1.mp3”?
我是 iphone 新手。我怀疑我的音频文件的路径位于资源文件夹的目录中,该路径是
/Users/Chary/Library/Application Support/iPhone Simulator/5.0/Applications/B02404E5-52DC-49B6-8DBB-C9946E4331AF/BiblePlayer.app/raj/1.mp3
我的问题是如何从整个路径中检索字符串“1.mp3”?
NSString *fullPath = @"…";
NSString *fileName = [fullPath lastPathComponent];
NSString *allString = @"/Users/Chary/Library/Application Support/iPhone Simulator/5.0/Applications/B02404E5-52DC-49B6-8DBB-C9946E4331AF/BiblePlayer.app/raj/1.mp3"
int slashPosition = [allString rangeOfString:@"/" options:NSBackwardsSearch].location;
NSString *function = [allString substringFromIndexslashPosition + 1];
这将为您提供最后一个斜杠后的文件路径
试试看:-
NSString *yourPath = @"/Users/Chary/Library/Application Support/iPhone Simulator/5.0/Applications/B02404E5-52DC-49B6-8DBB-C9946E4331AF/BiblePlayer.app/raj/1.mp3";
NSString *fileName = [yourPath lastPathComponent];
它可能会帮助你谢谢:)