mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-22 22:32:22 +00:00
60 lines
1.5 KiB
Swift
60 lines
1.5 KiB
Swift
//
|
|
// ShowNetworksViewController.swift
|
|
// ZeroTier One
|
|
//
|
|
// Created by Grant Limberg on 5/14/16.
|
|
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
|
|
|
@IBOutlet var tableView: NSTableView!
|
|
|
|
var networkList: [Network] = [Network]()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
// Do view setup here.
|
|
|
|
tableView.setDelegate(self)
|
|
tableView.setDataSource(self)
|
|
}
|
|
|
|
override func viewWillAppear() {
|
|
super.viewWillAppear()
|
|
|
|
ServiceCom.getNetworkList() { (networkList) -> Void in
|
|
NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in
|
|
self.networkList = networkList
|
|
self.tableView.reloadData()
|
|
}
|
|
}
|
|
}
|
|
|
|
// NSTableViewDataSource
|
|
|
|
func numberOfRowsInTableView(tableView: NSTableView) -> Int {
|
|
return networkList.count
|
|
}
|
|
|
|
// end NSTableViewDataSource
|
|
|
|
// NSTableViewDelegate
|
|
|
|
func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
if let cell = tableView.makeViewWithIdentifier("NetworkInfoCell", owner: nil) as? NetworkInfoCell {
|
|
let network = networkList[row]
|
|
cell.networkIdField.stringValue = String(network.nwid, radix: 16)
|
|
cell.networkNameField.stringValue = network.name
|
|
|
|
return cell
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// end NSTableViewDelegate
|
|
}
|