swift2 - call can throw error message Swift 2 -


i converted app swift 2, , of course, getting 1 error message:

"call can throw, not marked 'try' , eror not handled"

i did search here how fix this, answers more confusing me error itself. lol.

my application worked until converted swift 2. wonderful...

var myplayer = avaudioplayer()  var yoursound1 = nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource("remsound_01", oftype: "wav")!) func inityoursound() {     myplayer = avaudioplayer(contentsofurl: yoursound1, filetypehint: nil)     myplayer.preparetoplay()     myplayer.volume = 1.0 // < setting initial volume, still not perfected. } 

the error throws in following line:

myplayer = avaudioplayer(contentsofurl: yoursound1, filetypehint: nil)

how supposed fix this? understand swift trying "universalize" error handling, doing breaking simplest of code seems silly me.

thank help.

here pattern looking for.

<throwing function> // compiler error in swift 2     { try <throwing function> } catch { } 

in catch error can handle further.


Comments