Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 XCode(在 Swift 中)上制作一个简单的应用程序来播放音频文件,然后无限循环。根据Apple 的网站,我需要添加var loops: Bool { get set }到我的代码中;但我不确定如何以不会出错的方式将其与我当前的代码结合起来。
var loops: Bool { get set }
这是我到目前为止所拥有的:
let song = NSSound(named: "song.mp3")?.play() var loops: Bool { get set }
以这种方式尝试:
// create an instance let song = NSSound(named: "song.mp3") // set `loops` property to be true song?.loops = true // start to play song?.play()