有关在文档文件夹中获取文件的URL的问题。
我正在尝试将本地网址带到下一个viewcontroller来播放这首歌。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
MSHLocalPlayerVC *playerVC = [segue destinationViewController];
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *strURL = [documentsPath stringByAppendingPathComponent: [self.filePathArray objectAtIndex:[self.tableView indexPathForSelectedRow].row]];
playerVC.urlLocalSong = [NSURL URLWithString:strURL];
...
}
结果:
strURL:
/var/mobile/Containers/Data/Application/64000095-51F9-47D1-B152-6D1F8369A01F/Documents/mySong.mp3
playerVC.urlLocalSong:nil
为什么?
答案 0 :(得分:2)
尝试使用playerVC.urlLocalSong = [NSURL fileURLWithPath:strURL];