0

我是 iphone 编程新手。我想获取位于资源文件夹目录中的 mp3 文件的标题

资源文件夹结构如下

资源

raj(目录)---->1.mp3 ---->2.mp3

在这里,如果我得到它显示的路径,我知道要获取文件的路径

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

我有一个选择器视图,因为对于 1.mp3 和 2.mp3,我只需要显示像“1”、“2”这样的标题,但是如何才能像这样显示整个路径

所以,如果有人知道这一点,请帮助我。

4

2 回答 2

0
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
//Provide another path if you have folder in your directory
NSArray *arrDirVideos = [fileManager  contentsOfDirectoryAtPath:documentsDirectory error:nil];

它将为您在数组中提供的路径提供所有文件,例如 { 1.mp3,2.mp3,..} 所以现在您可以从数组的每个项目中删除 .mp3

于 2012-05-24T06:40:04.023 回答
0

用这个:

NSString * mp3FilePath = [[NSBundle mainBundle]
                                    pathForResource:@"1"
                                             ofType:@"mp3"];
于 2012-05-24T06:32:48.390 回答