diff --git a/AVRsack/ASBuilder.swift b/AVRsack/ASBuilder.swift index cc64167..e34e8b6 100644 --- a/AVRsack/ASBuilder.swift +++ b/AVRsack/ASBuilder.swift @@ -15,10 +15,10 @@ class ASBuilder { var termination : AnyObject? init() { - termination = NotificationCenter.defaultCenter.addObserverForName(NSTaskDidTerminateNotification, - object: nil, queue: nil, usingBlock: - { (notification: NSNotification) in - if notification.object as? NSTask == self.task { + termination = NotificationCenter.default.addObserver(forName: Task.didTerminateNotification, + object: nil, queue: nil, using: + { (notification: Notification) in + if notification.object as? Task == self.task { if self.task!.terminationStatus == 0 { if let cont = self.continuation { self.continuation = nil diff --git a/AVRsack/ASProjDoc.swift b/AVRsack/ASProjDoc.swift index ab5a8b2..f9b0b29 100644 --- a/AVRsack/ASProjDoc.swift +++ b/AVRsack/ASProjDoc.swift @@ -94,10 +94,10 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa recentProgrammers = userDefaults.object(forKey: kRecentProgrammersKey) as! [String] let nc = NotificationCenter.default - themeObserver = nc.addObserverForName(kBindingsKey, object: nil, queue: nil, usingBlock: { (NSNotification) in + themeObserver = nc.addObserver(forName: NSNotification.Name(kBindingsKey), object: nil, queue: nil, using: { (NSNotification) in self.editor?.setKeyboardHandler(keyboardHandler) }) - serialObserver = nc.addObserverForName(kASSerialPortsChanged, object: nil, queue: nil, usingBlock: { (NSNotification) in + serialObserver = nc.addObserver(forName: NSNotification.Name(kASSerialPortsChanged), object: nil, queue: nil, using: { (NSNotification) in if self.portTool != nil { self.rebuildPortMenu() } @@ -138,7 +138,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa } } } - outlineViewSelectionDidChange(NSNotification(name: "", object: nil)) + outlineViewSelectionDidChange(Notification(name: Notification.Name(""), object: nil)) menuNeedsUpdate(boardTool.menu!) menuNeedsUpdate(progTool.menu!) rebuildPortMenu() @@ -686,7 +686,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa keyboardHandler = ACEKeyboardHandler(rawValue: UInt(item.tag))! UserDefaults.standard.set( ACEKeyboardHandlerNames.humanName(for: keyboardHandler), forKey: kBindingsKey) - NotificationCenter.defaultCenter.postNotificationName(kBindingsKey, object: item) + NotificationCenter.default.post(name: NSNotification.Name(kBindingsKey), object: item) } override func validateUserInterfaceItem(_ anItem: NSValidatedUserInterfaceItem) -> Bool { diff --git a/AVRsack/ASSerialWin.swift b/AVRsack/ASSerialWin.swift index 1e58d9a..dc0070a 100644 --- a/AVRsack/ASSerialWin.swift +++ b/AVRsack/ASSerialWin.swift @@ -104,9 +104,9 @@ class ASSerialWin: NSWindowController { } let nc = NotificationCenter.default - serialObserver = nc.addObserverForName(kASSerialPortsChanged, object: nil, queue: nil, usingBlock: { (NSNotification) in - self.willChangeValueForKey("hasValidPort") - self.didChangeValueForKey("hasValidPort") + serialObserver = nc.addObserver(forName: NSNotification.Name(kASSerialPortsChanged), object: nil, queue: nil, using: { (NSNotification) in + self.willChangeValue(forKey: "hasValidPort") + self.didChangeValue(forKey: "hasValidPort") if self.task == nil { if self.hasValidPort { @@ -116,10 +116,10 @@ class ASSerialWin: NSWindowController { } } }) - termination = NotificationCenter.defaultCenter.addObserverForName(NSTaskDidTerminateNotification, - object: nil, queue: nil, usingBlock: - { (notification: NSNotification) in - if notification.object as? NSTask == self.task { + termination = NotificationCenter.default.addObserver(forName: Task.didTerminateNotification, + object: nil, queue: nil, using: + { (notification: Notification) in + if notification.object as? Task == self.task { self.task = nil self.portHandle = nil } @@ -246,9 +246,9 @@ class ASSerialWin: NSWindowController { keyboardHandler = ACEKeyboardHandler(rawValue: UInt(item.tag))! UserDefaults.standard.set( ACEKeyboardHandlerNames.humanName(for: keyboardHandler), forKey: "Bindings") - NotificationCenter.defaultCenter.postNotificationName("Bindings", object: item) + NotificationCenter.default.post(name: Notification.Name("Bindings"), object: item) } - + func validateUserInterfaceItem(anItem: NSValidatedUserInterfaceItem) -> Bool { if let menuItem = anItem as? NSMenuItem { if menuItem.action == Selector(("changeTheme:")) {