Fix notifications

This commit is contained in:
Matthias Neeracher 2016-11-13 13:13:40 +01:00 committed by Matthias Neeracher
parent 32d8adb1b1
commit 58015d3e78
3 changed files with 17 additions and 17 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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,7 +246,7 @@ 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 {