This file contains 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
struct TreadSafeDict<Key:Hashable, Element> { | |
let queue = DispatchQueue(label: "thread-safe-queue") | |
typealias DictionaryType = [Key : Element] | |
private var _elements = DictionaryType() | |
init(elements: DictionaryType) { | |
queue.sync { |
This file contains 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
// Return IP address of WiFi interface (en0) as a String, or `nil` | |
func getWiFiAddress() -> 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 } | |
// For each interface ... |