Avatar ·

How to properly use NSNotificationCenter addObserver in Swift?

Hello everyone! I'm new to Swift and trying to understand the notification mechanism. I need all active screens to be notified when app settings change (e.g., language switch). I heard that `NSNotificationCenter` is used for this, but I'm having issues using it.\n\nHere's my code:\n\n```swift\n// Posting notification\nNSNotificationCenter.defaultCenter().postNotificationName("LanguageChanged", object: nil)\n\n// Subscribing to notification (in viewDidLoad)\nNSNotificationCenter.defaultCenter().addObserver(self, selector: "languageChanged:", name: "LanguageChanged", object: nil)\n\n// Handler\nfunc languageChanged(notification: NSNotification) {\n print("Language changed!")\n}\n```\n\nBut Xcode gives a warning: `'addObserver:selector:name:object