Use modern structure for notifications

This commit is contained in:
Davide De Rosa 2019-11-02 11:32:16 +01:00
parent 9c92d1d567
commit 4ced1c499d
1 changed files with 5 additions and 7 deletions

View File

@ -40,14 +40,12 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self
extension NSNotification.Name {
/// A change in Wi-Fi state occurred.
public static let InterfaceObserverDidDetectWifiChange = NSNotification.Name("InterfaceObserverDidDetectWifiChange")
}
/// Observes changes in the current Wi-Fi network. /// Observes changes in the current Wi-Fi network.
public class InterfaceObserver: NSObject { public class InterfaceObserver: NSObject {
/// A change in Wi-Fi state occurred.
public static let didDetectWifiChange = NSNotification.Name("InterfaceObserverDidDetectWifiChange")
private var queue: DispatchQueue? private var queue: DispatchQueue?
private var timer: DispatchSourceTimer? private var timer: DispatchSourceTimer?
@ -88,7 +86,7 @@ public class InterfaceObserver: NSObject {
log.debug("SSID is now '\(current.maskedDescription)'") log.debug("SSID is now '\(current.maskedDescription)'")
if let last = lastWifiName, (current != last) { if let last = lastWifiName, (current != last) {
queue?.async { queue?.async {
NotificationCenter.default.post(name: .InterfaceObserverDidDetectWifiChange, object: nil) NotificationCenter.default.post(name: InterfaceObserver.didDetectWifiChange, object: nil)
} }
} }
} else { } else {