swift - 按需资源下载后使用文件 Swift 3

标签 swift on-demand-resources

按需资源放置。

大家好。 我已经为点播资源设置了标签,我已经编写了下载它的代码,但我不知道如何访问它?使用 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/

相关文章:

ios - 返回错误的设备方向

swift - 让UIButton点击后消失?

ios - NSManagedObjectContext 扩展中的通用函数中的奇怪 Swift 行为

ios - iOS 应用程序中的按需资源 AppStore 上传失败 - 不允许的路径

macos - 如何在 MacOS Catalyst 应用程序中启用按需资源

ios - 执行 segue 有时间限制吗?

ios - 如何在单元格、行和部分中构造不同的组件?

swift - 解析视频上传 - fatal error : unexpectedly found nil while unwrapping an Optional Value

ios - 使用按需资源自动上传 iOS AppStore