我试图在资源文件夹中获取 10 个 mp3 文件,并在按下按钮时播放它们。我在 NSMutableArray 中输入了 mp3 文件的名称,并在按下按钮后读取每个文件。
问题是 pathForResource: 不起作用(返回 nil)。如果我明确使用文件名 - 像 pathFoResource:@"song1.mp3" ofType:@"mp3"- 但如果我使用 pathForResource:valuem whwre valuem 是一个值为 song1 的 NSstring
希望你能帮忙
问候
NSString *cellValue0 = [listOfmp3 objectAtIndex:anumber];
NSString *valuem;
if ( [cellValue0 length] > 0 )
valuem = [cellValue0 substringToIndex:[cellValue0 length] - 4];
NSString *pdfPath2 = [[NSBundle mainBundle] pathForResource:valuem ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:pdfPath2];