LoginSignup
0
0

More than 5 years have passed since last update.

Swift4.2 foreground、background オブザーバー

Last updated at Posted at 2018-12-13

Swift4.2 foreground、background オブザーバー

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        NotificationCenter.default.addObserver( self,
 selector:#selector(background),
name: UIApplication.didEnterBackgroundNotification,object: nil)
        NotificationCenter.default.addObserver( self, selector: #selector(foreground),name: UIApplication.willEnterForegroundNotification,object: nil)
    }
    @objc func background() { print("background") }
    @objc func foreground() { print("foreground") }
}

参考箇所 スーパークラス

スクリーンショット 2018-12-13 21.20.00.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0