Merge remote-tracking branch 'origin/master' into swift-4.0-branch
diff --git a/Foundation/NSNotification.swift b/Foundation/NSNotification.swift
index 688b86a..09c052b 100644
--- a/Foundation/NSNotification.swift
+++ b/Foundation/NSNotification.swift
@@ -23,7 +23,7 @@
}
}
- private(set) open var name: Name
+ private(set) open var name: NSNotification.Name
private(set) open var object: Any?
@@ -33,8 +33,12 @@
/* do not invoke; not a valid initializer for this class */
fatalError()
}
+
+ public convenience init(name: NSNotification.Name, object: Any?) {
+ self.init(name: name, object: object, userInfo: nil)
+ }
- public init(name: Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) {
+ public init(name: NSNotification.Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) {
self.name = name
self.object = object
self.userInfo = userInfo
@@ -169,7 +173,11 @@
}
}
- open func post(name aName: Notification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable : Any]? = nil) {
+ open func post(name aName: NSNotification.Name, object anObject: Any?) {
+ post(name: aName, object: anObject, userInfo: nil)
+ }
+
+ open func post(name aName: NSNotification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable : Any]? = nil) {
let notification = Notification(name: aName, object: anObject, userInfo: aUserInfo)
post(notification)
}
@@ -188,7 +196,7 @@
})
}
- open func addObserver(forName name: Notification.Name?, object obj: Any?, queue: OperationQueue?, usingBlock block: @escaping (Notification) -> Void) -> NSObjectProtocol {
+ open func addObserver(forName name: NSNotification.Name?, object obj: Any?, queue: OperationQueue?, using block: @escaping (Notification) -> Void) -> NSObjectProtocol {
let object = NSObject()
let newObserver = NSNotificationReceiver()
diff --git a/Foundation/Notification.swift b/Foundation/Notification.swift
index d929dbe..9c307ec 100644
--- a/Foundation/Notification.swift
+++ b/Foundation/Notification.swift
@@ -18,7 +18,7 @@
public typealias ReferenceType = NSNotification
/// A tag identifying the notification.
- public var name: Name
+ public var name: Notification.Name
/// An object that the poster wishes to send to observers.
///
diff --git a/Foundation/NotificationQueue.swift b/Foundation/NotificationQueue.swift
index c493d45..5b43a40 100644
--- a/Foundation/NotificationQueue.swift
+++ b/Foundation/NotificationQueue.swift
@@ -76,11 +76,12 @@
removeRunloopObserver(self.asapRunloopObserver)
}
- open func enqueue(_ notification: Notification, postingStyle: PostingStyle) {
+ open func enqueue(_ notification: Notification, postingStyle: NotificationQueue.PostingStyle) {
enqueue(notification, postingStyle: postingStyle, coalesceMask: [.onName, .onSender], forModes: nil)
}
- open func enqueue(_ notification: Notification, postingStyle: PostingStyle, coalesceMask: NotificationCoalescing, forModes modes: [RunLoopMode]?) {
+ open func enqueue(_ notification: Notification, postingStyle: NotificationQueue.PostingStyle,
+ coalesceMask: NotificationQueue.NotificationCoalescing, forModes modes: [RunLoopMode]?) {
var runloopModes: [RunLoopMode] = [.defaultRunLoopMode]
if let modes = modes {
runloopModes = modes