按需资源放置。
大家好。 我已经为点播资源设置了标签,我已经编写了下载它的代码,但我不知道如何访问它?使用 swift 3
下面是我的代码。
在设置 ODR 之前,我从 main.bundle 获取音频。
try vox = AVAudioPlayer(contentsOf: URL(fileURLWithPath: Bundle.main.path(forResource: sV, ofType: "mp3")!))
try music = AVAudioPlayer(contentsOf: URL(fileURLWithPath: Bundle.main.path(forResource: sM, ofType: "mp3")!))
下载文件的代码。
request = NSBundleResourceRequest(tags: ["Stress"])
request.beginAccessingResources { (error) in
// Called on background thread
if error == nil {
OperationQueue.main.addOperation({ () -> Void in
})
}
}
我只是不知道如何访问下载后的文件?
最佳答案
来自documentation对于 NSBundleResourceRequest.init(tags:)
:
The managed resources are loaded into the main bundle
关于swift - 按需资源下载后使用文件 Swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42880806/