Swift 2 has a completely new error handling system, you can read about it here: Swift 2 Error Handling .
In your case, the AVAudioPlayer constructor may AVAudioPlayer error. Swift will not allow you to use methods that cause errors in property initializers, because there is no way to handle them. Instead, do not initialize the property until the init view controller.
var testAudio:AVAudioPlayer; init() { do { try testAudio = AVAudioPlayer(contentsOfURL: NSURL (fileURLWithPath: NSBundle.mainBundle().pathForResource("testAudio", ofType: "wav")!), fileTypeHint:nil) } catch {
This gives you the ability to handle any errors that may occur when creating an audio player, and will stop Xcode by giving you warnings.
Seana source share