VPN v2
This commit is contained in:
23
main/Extensions/Notifications.swift
Normal file
23
main/Extensions/Notifications.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
import Foundation
|
||||
|
||||
let NotifyVPNStateChanged = NSNotification.Name("GlassVPNStateChanged") // VPNState!
|
||||
let NotifyFilterChanged = NSNotification.Name("PSIFilterSettingsChanged") // nil!
|
||||
let NotifyLogHistoryReset = NSNotification.Name("PSILogHistoryReset") // nil!
|
||||
|
||||
|
||||
extension NSNotification.Name {
|
||||
func post(_ obj: Any? = nil) {
|
||||
NotificationCenter.default.post(name: self, object: obj)
|
||||
}
|
||||
func postOnMainThread(_ obj: Any? = nil) {
|
||||
DispatchQueue.main.async { NotificationCenter.default.post(name: self, object: obj) }
|
||||
}
|
||||
/// You are responsible for removing the returned object in a `deinit` block.
|
||||
// @discardableResult func observe(queue: OperationQueue? = nil, using block: @escaping (Notification) -> Void) -> NSObjectProtocol {
|
||||
// NotificationCenter.default.addObserver(forName: self, object: nil, queue: queue, using: block)
|
||||
// }
|
||||
/// On iOS 9.0+ you don't need to unregister the observer.
|
||||
func observe(call: Selector, on target: Any, obj: Any? = nil) {
|
||||
NotificationCenter.default.addObserver(target, selector: call, name: self, object: obj)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user