This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Put the code in the class that actually has the data. Have the class register for the UIApplicationDidEnterBackgroundNotification notification. | |
// Put this in the `init` method | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backgrounding) name:UIApplicationDidEnterBackgroundNotification object:nil]; | |
// The method that gets called | |
- (void)backgrounding { | |
// save the data | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AVFoundation | |
var audioPlayer: AVAudioPlayer! | |
let soundURL = Bundle.main.url(forResource: "soundName", withExtension: "soundFormat") | |
do { | |
audioPlayer = try AVAudioPlayer(contentsOf: soundURL!) | |
} catch { | |
print(error) |
NewerOlder