ios - Stopping or Playing AVAudioPlayer From Another Class - App Crashes - Swift -
I have an aviable player in my appellate to play at startup. It continues to play in the entire app, but when I try to stop or run the player in a different class, the app crashes with that EXC_BAD_ACCESS on that line.
AppDelegate.swift
Import AVFoundation @UIApplicationMain Class AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow? Var path = NSBundle.mainBundle (). PathForResource ("backgroundMusic", type: "wav") var soundtrack = AVAudioPlayer () func application (application: UIApplication, didFinishLaunchingWithOptions Launch Option: NSDictionary?) - & gt; Other Words for Sound Class .swift func aFunction () {appDelegate = AppDelegate () appDelegate.soundTrack.stop () // Here the application crashes Thank you for any help!
p> >> AppDelegate () Creating a new example; The variables that have not started. You want to get a UiApplications sharing representative: appDelegate = UIApplication.sharedApplication () Delegate as AppDelegate
Comments
Post a Comment