mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-03 03:36:41 +00:00
Work around for several strange corner cases in Automatic Reference Counting in Apple's runtime
This commit is contained in:
parent
decb4261d4
commit
ba0a45365c
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user