gpt4 book ai didi

ios - 通过 NSBundle 访问声音文件 - pathForResource

转载 作者:行者123 更新时间:2023-11-30 13:13:25 25 4
gpt4 key购买 nike

所以我只是想通过一些在线视频类(class)来进入 iOS 编程。问题是,这些不是 Swift 3 的最新版本。

在我目前的项目中,需要使用以下命令通过 NSBundle-Framework 导入声音文件:

let path = NSBundle.mainBundle().pathForResource(name, ofType:)

问题是,我无法在 Swift 3 中运行它,而且我无法从 Apple 文档中获取正确的内容。所以我的代码如下所示:

import AVFoundation
import Foundation //don't know if this is right by 100 per cent

let path = NSBundle.mainBundle().pathForResource("btn", ofType: "wav")

但它似乎甚至不知道 NSBundle 类,因为自动完成甚至没有为我提供任何 NSBundle 功能。我似乎找不到 Swift 3 中更改的正确部分来使这个东西正常工作。这里有人能帮我解决这个问题吗?

最佳答案

我相信这是票:

let path = Bundle.main.path(forResource: "btn", ofType: "wav")

关于ios - 通过 NSBundle 访问声音文件 - pathForResource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38489300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com