1

私はiphoneを初めて使用します.パスがリソースフォルダーのディレクトリに配置されているオーディオファイルのパスを持っていることに少し疑問があります

/Users/Chary/Library/Application Support/iPhone Simulator/5.0/Applications/B02404E5-52DC-49B6-8DBB-C9946E4331AF/BiblePlayer.app/raj/1.mp3

私の質問は、そのパス全体から文字列「1.mp3」を取得する方法ですか?

4

3 に答える 3

4
NSString *fullPath = @"…";
NSString *fileName = [fullPath lastPathComponent];
于 2012-05-24T07:27:43.407 に答える
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];

それはあなたに感謝するのに役立つかもしれません:)

于 2012-05-24T08:22:53.207 に答える
1
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];

これにより、最後のスラッシュの後のファイルのパスが取得されます

于 2012-05-24T07:28:23.657 に答える