post 發送

NotificationCenter.default.post(name: Notification.Name("ResignActiveNotification"), object: nil, userInfo: nil)

宣告監聽

NotificationCenter.default.addObserver(self, selector: #selector(self.applicationWillResignActive), name: NSNotification.Name(rawValue: "ResignActiveNotification"), object: nil)

執行func

@objc func applicationWillResignActive() {
    print("123")
}

Categorized in: