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?


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -