xcode - Sound ID failing in Swift -
i have following code linked button should play audio.
var exampleplayer = avaudioplayer() var example = nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource("example", oftype: "mp3")!) func exampleaudio(){ exampleplayer = avaudioplayer(contentsofurl: example, error: nil) exampleplayer.preparetoplay() exampleplayer.play() } @ibaction func anotherexampleaudio(sender: anyobject) { exampleaudio() }
this error i'm getting.
fatal error: unexpectedly found nil while unwrapping optional value
what's going on?