Notification Center

Notification Center Offical Documents, Notification Programming Topics

class var default: NotificationCenter { get }

Adding and Removing Notification Observers

Posting Notifications

Sample Code

포스팅

@IBAction func notiPostBtn(_ sender: UIButton) {
        NotificationCenter.default.post(name: NSNotification.Name.init("TestNoti"), object:ThirdTF!.text, userInfo: ["noti":"info"])
    }

옵저빙

override func viewDidLoad() {
    super.viewDidLoad()
    NotificationCenter.default.addObserver(forName: Notification.Name.init("TestNoti"), object: nil, queue: nil) { (noti) in
        if let text = noti.object as? String {
            self.secondLB.text = text
        }
    }
}