Refactor.

This commit is contained in:
Qiu Yuzhou
2017-03-18 12:20:51 +08:00
parent c9b3b80008
commit 72985b32ae
4 changed files with 4 additions and 5 deletions

View File

@ -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

View File

@ -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")

View File

@ -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) {

View File

@ -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