2

I'm attempting to make a simple application on XCode (in Swift) that plays an audio file, then keeps looping infinitely. According to Apple's website, I need to add var loops: Bool { get set } to my code; but I'm not sure how to combine that with my current code in a way that doesn't give an error.

This is what I have so far:

let song = NSSound(named: "song.mp3")?.play()
var loops: Bool { get set }
htmlcat
  • 336
  • 3
  • 10

1 Answers1

2

Try in this way:

// create an instance    
let song = NSSound(named: "song.mp3")

// set `loops` property to be true    
song?.loops = true

// start to play   
song?.play()
Evgeny Karkan
  • 8,782
  • 2
  • 32
  • 38