Skip to content

Instantly share code, notes, and snippets.

@ericjames
Created June 28, 2017 20:53
Show Gist options
  • Save ericjames/9da8ebe5676dd05a74feb332ea634006 to your computer and use it in GitHub Desktop.
Save ericjames/9da8ebe5676dd05a74feb332ea634006 to your computer and use it in GitHub Desktop.
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self,
selector: #selector(applicationDidEnterBackground),
name: NSNotification.Name.UIApplicationDidEnterBackground,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(applicationDidEnterForeground),
name: NSNotification.Name.UIApplicationWillEnterForeground,
object: nil)
}
deinit {
NotificationCenter.default.removeObserver(self)
NotificationCenter.default.removeObserver(self)
}
func applicationDidEnterBackground() {
log(text: "App backgrounded", pauseLog: false)
}
func applicationDidEnterForeground() {
log(text: "App foregrounded", pauseLog: false)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment