How do you add an observer in Swift to the default notification center? I\'m trying to port this line of code that sends a notification when the battery level changes.
NSNotificationCenter add observer syntax in Swift 4.0 for iOS 11
NotificationCenter.default.addObserver(self, selector: #selector(keyboardShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
This is for keyboardWillShow notification name type. Other type can be selected from the available option
the Selector is of type @objc func which handle how the keyboard will show ( this is your user function )