fix 通知中心
This commit is contained in:
parent
ac01e68311
commit
98386ded25
@ -22,7 +22,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
let msg = shared?.string(forKey: "test_msg")
|
||||
SDLLogger.log("NE read message: \(msg ?? "failed")", for: .debug)
|
||||
|
||||
DarwinNotificationCenter.shared.post(.vpnStatusChanged)
|
||||
SDLNotificationCenter.shared.post(.vpnStatusChanged)
|
||||
|
||||
// 如果当前在运行状态,不允许重复请求
|
||||
guard self.contextActor == nil else {
|
||||
|
||||
@ -56,7 +56,7 @@ final class SDLTunnelAppNotifier {
|
||||
|
||||
shared.set(data, forKey: self.eventKey)
|
||||
shared.synchronize()
|
||||
DarwinNotificationCenter.shared.post(.tunnelEventChanged)
|
||||
SDLNotificationCenter.shared.post(.tunnelEventChanged)
|
||||
}
|
||||
|
||||
func clear() {
|
||||
@ -66,6 +66,6 @@ final class SDLTunnelAppNotifier {
|
||||
|
||||
shared.removeObject(forKey: self.eventKey)
|
||||
shared.synchronize()
|
||||
DarwinNotificationCenter.shared.post(.tunnelEventChanged)
|
||||
SDLNotificationCenter.shared.post(.tunnelEventChanged)
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ extension DarwinNotificationName {
|
||||
|
||||
|
||||
// MARK: - Manager
|
||||
public final class DarwinNotificationCenter {
|
||||
public static let shared = DarwinNotificationCenter()
|
||||
public final class SDLNotificationCenter {
|
||||
public static let shared = SDLNotificationCenter()
|
||||
|
||||
private let center = CFNotificationCenterGetDarwinNotifyCenter()
|
||||
|
||||
@ -50,7 +50,7 @@ public final class DarwinNotificationCenter {
|
||||
return
|
||||
}
|
||||
|
||||
let instance = Unmanaged<DarwinNotificationCenter>
|
||||
let instance = Unmanaged<SDLNotificationCenter>
|
||||
.fromOpaque(observer)
|
||||
.takeUnretainedValue()
|
||||
|
||||
@ -93,7 +93,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
shared?.set("App says hello", forKey: "test_msg")
|
||||
shared?.synchronize()
|
||||
|
||||
DarwinNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in
|
||||
SDLNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in
|
||||
NSLog("DarwinNotificationCenter get message: \(name)")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user