diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 2a631f9..0a19220 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -120,7 +120,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele self.updateCopyHttpProxyExportMenu() }) - notifyCenter.addObserver(forName: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil, queue: nil + notifyCenter.addObserver(forName: NOTIFY_SERVER_PROFILES_CHANGED, object: nil, queue: nil , using: { (note) in let profileMgr = ServerProfileManager.instance diff --git a/ShadowsocksX-NG/Notifications.swift b/ShadowsocksX-NG/Notifications.swift index 3778826..974910c 100644 --- a/ShadowsocksX-NG/Notifications.swift +++ b/ShadowsocksX-NG/Notifications.swift @@ -8,8 +8,7 @@ import Foundation -let NOTIFY_SERVER_PROFILES_CHANGED = "NOTIFY_SERVER_PROFILES_CHANGED" -let NOTIFY_INVALIDE_QR = "NOTIFY_INVALIDE_QR" +let NOTIFY_SERVER_PROFILES_CHANGED = Notification.Name(rawValue: "NOTIFY_SERVER_PROFILES_CHANGED") let NOTIFY_CONF_CHANGED = Notification.Name(rawValue: "NOTIFY_CONF_CHANGED") diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index f6375f6..ebe4481 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -145,7 +145,7 @@ class PreferencesWindowController: NSWindowController NotificationCenter.default - .post(name: Notification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil) + .post(name: NOTIFY_SERVER_PROFILES_CHANGED, object: nil) } @IBAction func cancel(_ sender: NSButton) { diff --git a/ShadowsocksX-NG/ServerProfileManager.swift b/ShadowsocksX-NG/ServerProfileManager.swift index dbed875..b0c8467 100644 --- a/ShadowsocksX-NG/ServerProfileManager.swift +++ b/ShadowsocksX-NG/ServerProfileManager.swift @@ -107,7 +107,7 @@ class ServerProfileManager: NSObject { self.profiles.append(profile) self.save() } - NotificationCenter.default.post(name: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil) + NotificationCenter.default.post(name: NOTIFY_SERVER_PROFILES_CHANGED, object: nil) let configsCount = (jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]).count let notification = NSUserNotification() notification.title = "Import Server Profile succeed!".localized