我想从 Xcode 7 中的资产目录中检索非 jpg/png 文件。我看到现在可以将任何类型的数据添加到资产目录中。
所以我这样做的方式是在将 gif/video 从 Xcode 项目移动到资产目录之前工作
private struct WalkthroughVideo {
static let name = "tokyo"
static let type = "mp4"
}
private var moviePlayer : AVPlayerViewController? = {
guard let path = NSBundle.mainBundle().pathForResource(WalkthroughVideo.name, ofType: WalkthroughVideo.type) else {
return nil
}
let url = NSURL.fileURLWithPath(path)
let playerViewController = AVPlayerViewController()
playerViewController.player = AVPlayer(URL: url)
return playerViewController
}()
所以现在路径为零。它找不到文件。有没有一种新的方法来检索数据集?