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? var termination : AnyObject?
init() { init() {
termination = NotificationCenter.defaultCenter.addObserverForName(NSTaskDidTerminateNotification, termination = NotificationCenter.default.addObserver(forName: Task.didTerminateNotification,
object: nil, queue: nil, usingBlock: object: nil, queue: nil, using:
{ (notification: NSNotification) in { (notification: Notification) in
if notification.object as? NSTask == self.task { if notification.object as? Task == self.task {
if self.task!.terminationStatus == 0 { if self.task!.terminationStatus == 0 {
if let cont = self.continuation { if let cont = self.continuation {
self.continuation = nil self.continuation = nil

View File

@ -94,10 +94,10 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
recentProgrammers = userDefaults.object(forKey: kRecentProgrammersKey) as! [String] recentProgrammers = userDefaults.object(forKey: kRecentProgrammersKey) as! [String]
let nc = NotificationCenter.default 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) 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 { if self.portTool != nil {
self.rebuildPortMenu() 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(boardTool.menu!)
menuNeedsUpdate(progTool.menu!) menuNeedsUpdate(progTool.menu!)
rebuildPortMenu() rebuildPortMenu()
@ -686,7 +686,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
keyboardHandler = ACEKeyboardHandler(rawValue: UInt(item.tag))! keyboardHandler = ACEKeyboardHandler(rawValue: UInt(item.tag))!
UserDefaults.standard.set( UserDefaults.standard.set(
ACEKeyboardHandlerNames.humanName(for: keyboardHandler), forKey: kBindingsKey) 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 { override func validateUserInterfaceItem(_ anItem: NSValidatedUserInterfaceItem) -> Bool {

View File

@ -104,9 +104,9 @@ class ASSerialWin: NSWindowController {
} }
let nc = NotificationCenter.default let nc = NotificationCenter.default
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
self.willChangeValueForKey("hasValidPort") self.willChangeValue(forKey: "hasValidPort")
self.didChangeValueForKey("hasValidPort") self.didChangeValue(forKey: "hasValidPort")
if self.task == nil { if self.task == nil {
if self.hasValidPort { if self.hasValidPort {
@ -116,10 +116,10 @@ class ASSerialWin: NSWindowController {
} }
} }
}) })
termination = NotificationCenter.defaultCenter.addObserverForName(NSTaskDidTerminateNotification, termination = NotificationCenter.default.addObserver(forName: Task.didTerminateNotification,
object: nil, queue: nil, usingBlock: object: nil, queue: nil, using:
{ (notification: NSNotification) in { (notification: Notification) in
if notification.object as? NSTask == self.task { if notification.object as? Task == self.task {
self.task = nil self.task = nil
self.portHandle = nil self.portHandle = nil
} }
@ -246,9 +246,9 @@ class ASSerialWin: NSWindowController {
keyboardHandler = ACEKeyboardHandler(rawValue: UInt(item.tag))! keyboardHandler = ACEKeyboardHandler(rawValue: UInt(item.tag))!
UserDefaults.standard.set( UserDefaults.standard.set(
ACEKeyboardHandlerNames.humanName(for: keyboardHandler), forKey: "Bindings") 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 { func validateUserInterfaceItem(anItem: NSValidatedUserInterfaceItem) -> Bool {
if let menuItem = anItem as? NSMenuItem { if let menuItem = anItem as? NSMenuItem {
if menuItem.action == Selector(("changeTheme:")) { if menuItem.action == Selector(("changeTheme:")) {