I've been working on an App with Swift on the IOS where when you press a button it makes sound (I'm a beginner). This block of code though has been giving me problems, the code works when I just put "The Wilhelm scream sound effect", but when I try to put string it gives me the "ViewController.Type does not have a member named scream" error.
I've been stuck on this for a while, so any help would be appreciated.
class ViewController: UIViewController {
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
let scream: String = "The Wilhelm scream sound effect"
var pianoSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(scream, ofType: "mp3")!)
var audioPlayer = AVAudioPlayer()
}
Aucun commentaire:
Enregistrer un commentaire