Work around for several strange corner cases in Automatic Reference Counting in Apple's runtime
This commit is contained in:
@@ -69,7 +69,7 @@ void sharedFileListDidChange(LSSharedFileListRef inList, void *context)
|
|||||||
if (wantedURL == NULL || fileList == NULL)
|
if (wantedURL == NULL || fileList == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
NSArray *listSnapshot = (__bridge NSArray*)LSSharedFileListCopySnapshot(fileList, NULL);
|
NSArray *listSnapshot = (__bridge_transfer NSArray*)LSSharedFileListCopySnapshot(fileList, NULL);
|
||||||
for (id itemObject in listSnapshot) {
|
for (id itemObject in listSnapshot) {
|
||||||
LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef) itemObject;
|
LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef) itemObject;
|
||||||
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
|
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
|
||||||
|
|||||||
@@ -177,7 +177,11 @@ class Network: NSObject, NSCoding {
|
|||||||
|
|
||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder aDecoder: NSCoder) {
|
||||||
if aDecoder.containsValueForKey(PropertyKeys.addressesKey) {
|
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) {
|
if aDecoder.containsValueForKey(PropertyKeys.bridgeKey) {
|
||||||
@@ -193,7 +197,8 @@ class Network: NSObject, NSCoding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if aDecoder.containsValueForKey(PropertyKeys.macKey) {
|
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) {
|
if aDecoder.containsValueForKey(PropertyKeys.mtuKey) {
|
||||||
@@ -201,7 +206,9 @@ class Network: NSObject, NSCoding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if aDecoder.containsValueForKey(PropertyKeys.nameKey) {
|
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) {
|
if aDecoder.containsValueForKey(PropertyKeys.netconfKey) {
|
||||||
|
|||||||
@@ -42,8 +42,13 @@ class NetworkMonitor: NSObject {
|
|||||||
let filePath = dataFile()
|
let filePath = dataFile()
|
||||||
|
|
||||||
if NSFileManager.defaultManager().fileExistsAtPath(filePath) {
|
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
|
ServiceCom.getNetworkList() { (networkList) -> Void in
|
||||||
|
|||||||
@@ -161,9 +161,8 @@ class ServiceCom: NSObject {
|
|||||||
|
|
||||||
static func leaveNetwork(network: String) {
|
static func leaveNetwork(network: String) {
|
||||||
let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())"
|
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)
|
let request = NSMutableURLRequest(URL: u)
|
||||||
request.HTTPMethod = "DELETE"
|
request.HTTPMethod = "DELETE"
|
||||||
|
|
||||||
|
|||||||
@@ -112,8 +112,7 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable
|
|||||||
cell.addressesField.stringValue = ""
|
cell.addressesField.stringValue = ""
|
||||||
|
|
||||||
for nw in network.assignedAddresses {
|
for nw in network.assignedAddresses {
|
||||||
cell.addressesField.stringValue += nw
|
cell.addressesField.stringValue += "\(nw)\n"
|
||||||
cell.addressesField.stringValue += "\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user