Avatar ·

Como usar corretamente o NSNotificationCenter addObserver em Swift?

Olá a todos! Sou novo em Swift e estou tentando entender o mecanismo de notificações. Preciso que, ao alterar as configurações no aplicativo (por exemplo, mudar o idioma), todas as telas ativas sejam notificadas. Ouvi dizer que para isso se usa `NSNotificationCenter`, mas estou tendo problemas com seu uso.\n\nAqui está meu código:\n\n```swift\n// Envio da notificação\nNSNotificationCenter.defaultCenter().postNotificationName("LanguageChanged", object: nil)\n\n// Inscrição na notificação (no viewDidLoad)\nNSNotificationCenter.defaultCenter().addObserver(self, selector: "languageChanged:", name: "LanguageChanged", object: nil)\n\n// Manipulador\nfunc languageChanged(notification: NSNotification) {\n print("Language changed!")\n}\n```\n\nMas o Xcode exibe um aviso: `'addObserver:selector:name:object`