This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //#include <ifaddrs.h> in bridging-header first. | |
| fileprivate func getIPAddress() -> String? { | |
| var address : [String]? = [] | |
| // Get list of all interfaces on the local machine: | |
| var ifaddr : UnsafeMutablePointer<ifaddrs>? | |
| guard getifaddrs(&ifaddr) == 0 else { return nil} | |
| guard let firstAddr = ifaddr else { return nil} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //http://stackoverflow.com/questions/41940994/closure-cannot-implicitly-capture-a-mutating-self-paramter/41941810#41941810 | |
| private func capture(with block: @escaping () -> ()) { block() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let sdevices = devices.flatMap({ (device: Device) -> String in | |
| return "\(device.brand)-\(device.hostname)-\(device.ipAddress)-\(device.macAddress)\n" | |
| }).flatMap({$0}).joined() | |
| DispatchQueue.main.async { | |
| JDAlert(title: "Found \(devices.count) Device(s).", message: sdevices, preferredStyle: .alert) | |
| .addAction(title: "OK", style: .default) { _ in } | |
| .show() | |
| } |
NewerOlder