func checkIfFirstLaunch(){ if UserDefaults.standard.bool(forKey: "HasLaunchedBefore"){ print("App has launched before") } else { print("This is the first launch ever!") UserDefaults.standard.set(true, forKey: "HasLaunchedBefore") UserDefaults.standard.set(0.0, forKey: "Slider Value Key") UserDefaults.standard.synchronize() } func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool{ print("App Delegate: will finish launching") } }
override func viewDidLoad(){ super.viewDidLoad() do { audioPlayer = try AVAudioPlayer(contentsof: receivedAudio.filePathUrl as URL) } catch _ { audioPlayer = nil } audioPalyer.enableRate = true audioEngine = AVAudioEngine() do { audioFile = try AVAudioFile(forReading: receivedAudio.filePathUrl as URL) } catch _ { audioFile = nil } sliderView.value = UserDefaults.standard.float(forKey: SliderValueKey) setUserInterfaceToPlayMode(false) } @IBAction func playAudio(_ sender: UIButton){ let pitch = sliderView.value playAudioWithVariablePitch(pitch) setUserInterfaceToPlayMode(true) UserDefaults.standard.set(sliderView.value, forKey: SliderValueKey) }