Linked Questions

Popular Questions

Im learning notification centers right now and am getting this error while trying to register an observer: Cannot convert value of type 'Selector' to expected argument type 'String'

My observer code:

NotificationCenter.addObserver(self, forKeyPath: #selector(receivedMsg), options: Notification.Name("NC1"), context: nil)

Function receivedMsg:

 @objc func receivedMsg() {
print("MSG Received")
}

Working off this tutorial: https://www.hackingwithswift.com/example-code/system/how-to-post-messages-using-notificationcenter

Why am I getting this error and what can I do to fix it? (Swift 4.2)

Related Questions