在NSURL中存储本地路径
有关获取文档文件夹中文件URL的问题。在NSURL中存储本地路径
我想把本地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
为什么?
回答:
尝试使用playerVC.urlLocalSong = [NSURL fileURLWithPath:strURL];
以上是 在NSURL中存储本地路径 的全部内容, 来源链接: utcz.com/qa/257763.html