NotificationCenter

 

Ref. Link

https://youtu.be/srqiDnLEocA



class ViewController: UIViewController{

    

    override func viewDidLoad() {

        super.viewDidLoad()

        

        NotificationCenter.default.addObserver(self, selector:             

#selector(notificationMethodCall), name: .noti1, object: nil)


        // Fire a notification

        NotificationCenter.default.post(name: .noti1, object: nil)

        

    }

    @objc func notificationMethodCall() {

        //Notification will be called

    }

}



//MARK: Extenstion test

extension Notification.Name {

    static let noti1 = Notification.Name("Noti")

    

}



Comments

Popular posts from this blog

PUSH Notification