diff --git a/ZeroTier One/LaunchAtLoginController.m b/ZeroTier One/LaunchAtLoginController.m index f8aaafa00..53eb2b086 100644 --- a/ZeroTier One/LaunchAtLoginController.m +++ b/ZeroTier One/LaunchAtLoginController.m @@ -69,7 +69,7 @@ void sharedFileListDidChange(LSSharedFileListRef inList, void *context) if (wantedURL == NULL || fileList == NULL) return NULL; - NSArray *listSnapshot = (__bridge NSArray*)LSSharedFileListCopySnapshot(fileList, NULL); + NSArray *listSnapshot = (__bridge_transfer NSArray*)LSSharedFileListCopySnapshot(fileList, NULL); for (id itemObject in listSnapshot) { LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef) itemObject; UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; diff --git a/ZeroTier One/Network.swift b/ZeroTier One/Network.swift index b5f6b4235..451516864 100644 --- a/ZeroTier One/Network.swift +++ b/ZeroTier One/Network.swift @@ -177,7 +177,11 @@ class Network: NSObject, NSCoding { required init?(coder aDecoder: NSCoder) { if aDecoder.containsValueForKey(PropertyKeys.addressesKey) { - self.assignedAddresses = aDecoder.decodeObjectForKey(PropertyKeys.addressesKey) as! [String] + let addrs = aDecoder.decodeObjectForKey(PropertyKeys.addressesKey) as! [String] + + for a in addrs { + self.assignedAddresses.append(a) + } } if aDecoder.containsValueForKey(PropertyKeys.bridgeKey) { @@ -193,7 +197,8 @@ class Network: NSObject, NSCoding { } if aDecoder.containsValueForKey(PropertyKeys.macKey) { - self.mac = aDecoder.decodeObjectForKey(PropertyKeys.macKey) as! String + let mac = aDecoder.decodeObjectForKey(PropertyKeys.macKey) as! String + self.mac = mac } if aDecoder.containsValueForKey(PropertyKeys.mtuKey) { @@ -201,7 +206,9 @@ class Network: NSObject, NSCoding { } if aDecoder.containsValueForKey(PropertyKeys.nameKey) { - self.name = aDecoder.decodeObjectForKey(PropertyKeys.nameKey) as! String + let name = aDecoder.decodeObjectForKey(PropertyKeys.nameKey) as! String + + self.name = name } if aDecoder.containsValueForKey(PropertyKeys.netconfKey) { diff --git a/ZeroTier One/NetworkMonitor.swift b/ZeroTier One/NetworkMonitor.swift index d6ab55eed..c81ac47de 100644 --- a/ZeroTier One/NetworkMonitor.swift +++ b/ZeroTier One/NetworkMonitor.swift @@ -42,8 +42,13 @@ class NetworkMonitor: NSObject { let filePath = dataFile() if NSFileManager.defaultManager().fileExistsAtPath(filePath) { - self.savedNetworks = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] + let networks = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] + self.savedNetworks.removeAll() + + for n in networks { + self.savedNetworks.append(n) + } } ServiceCom.getNetworkList() { (networkList) -> Void in diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index 4c920ad22..2a98ec36d 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -161,9 +161,8 @@ class ServiceCom: NSObject { static func leaveNetwork(network: String) { let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())" - let url = NSURL(string: urlString) - if let u = url { + if let u = NSURL(string: urlString) { let request = NSMutableURLRequest(URL: u) request.HTTPMethod = "DELETE" diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index cb0170754..394a6bdc9 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -112,8 +112,7 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable cell.addressesField.stringValue = "" for nw in network.assignedAddresses { - cell.addressesField.stringValue += nw - cell.addressesField.stringValue += "\n" + cell.addressesField.stringValue += "\(nw)\n" }