mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-14 02:27:38 -07:00
Factored network updates into its own class. Delivered via notification
This commit is contained in:
parent
bae0060552
commit
c8f85ffec9
6 changed files with 145 additions and 81 deletions
|
@ -21,8 +21,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
|
||||
var transientMonitor: AnyObject? = nil
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
let monitor = NetworkMonitor()
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
let nc = NSNotificationCenter.defaultCenter()
|
||||
nc.addObserver(self, selector: #selector(onNetworkListUpdated(_:)), name: networkUpdateKey, object: nil)
|
||||
|
||||
statusItem.image = NSImage(named: "MenuBarIconMac")
|
||||
|
||||
|
@ -50,6 +53,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
|
||||
func applicationWillTerminate(aNotification: NSNotification) {
|
||||
// Insert code here to tear down your application
|
||||
let nc = NSNotificationCenter.defaultCenter()
|
||||
nc.removeObserver(self)
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,5 +94,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
func quit() {
|
||||
NSApp.performSelector(#selector(NSApp.terminate(_:)), withObject: nil, afterDelay: 0.0)
|
||||
}
|
||||
|
||||
func onNetworkListUpdated(note: NSNotification) {
|
||||
let netList = note.userInfo!["networks"] as! [Network]
|
||||
(networkListPopover.contentViewController as! ShowNetworksViewController).setNetworks(netList)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue