Skip to content

Commit 6f11976

Browse files
authored
Revert "Fix Notification API signatures to match Darwin"
1 parent f3e2f78 commit 6f11976

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

Foundation/NSNotification.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ open class NSNotification: NSObject, NSCopying, NSCoding {
2323
}
2424
}
2525

26-
private(set) open var name: NSNotification.Name
26+
private(set) open var name: Name
2727

2828
private(set) open var object: Any?
2929

@@ -33,12 +33,8 @@ open class NSNotification: NSObject, NSCopying, NSCoding {
3333
/* do not invoke; not a valid initializer for this class */
3434
fatalError()
3535
}
36-
37-
public convenience init(name: NSNotification.Name, object: Any?) {
38-
self.init(name: name, object: object, userInfo: nil)
39-
}
4036

41-
public init(name: NSNotification.Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) {
37+
public init(name: Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) {
4238
self.name = name
4339
self.object = object
4440
self.userInfo = userInfo
@@ -173,11 +169,7 @@ open class NotificationCenter: NSObject {
173169
}
174170
}
175171

176-
open func post(name aName: NSNotification.Name, object anObject: Any?) {
177-
post(name: aName, object: anObject, userInfo: nil)
178-
}
179-
180-
open func post(name aName: NSNotification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable : Any]? = nil) {
172+
open func post(name aName: Notification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable : Any]? = nil) {
181173
let notification = Notification(name: aName, object: anObject, userInfo: aUserInfo)
182174
post(notification)
183175
}
@@ -196,7 +188,7 @@ open class NotificationCenter: NSObject {
196188
})
197189
}
198190

199-
open func addObserver(forName name: NSNotification.Name?, object obj: Any?, queue: OperationQueue?, using block: @escaping (Notification) -> Void) -> NSObjectProtocol {
191+
open func addObserver(forName name: Notification.Name?, object obj: Any?, queue: OperationQueue?, usingBlock block: @escaping (Notification) -> Void) -> NSObjectProtocol {
200192
let object = NSObject()
201193

202194
let newObserver = NSNotificationReceiver()

Foundation/Notification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct Notification : ReferenceConvertible, Equatable, Hashable {
1818
public typealias ReferenceType = NSNotification
1919

2020
/// A tag identifying the notification.
21-
public var name: Notification.Name
21+
public var name: Name
2222

2323
/// An object that the poster wishes to send to observers.
2424
///

Foundation/NotificationQueue.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ open class NotificationQueue: NSObject {
7676
removeRunloopObserver(self.asapRunloopObserver)
7777
}
7878

79-
open func enqueue(_ notification: Notification, postingStyle: NotificationQueue.PostingStyle) {
79+
open func enqueue(_ notification: Notification, postingStyle: PostingStyle) {
8080
enqueue(notification, postingStyle: postingStyle, coalesceMask: [.onName, .onSender], forModes: nil)
8181
}
8282

83-
open func enqueue(_ notification: Notification, postingStyle: NotificationQueue.PostingStyle,
84-
coalesceMask: NotificationQueue.NotificationCoalescing, forModes modes: [RunLoopMode]?) {
83+
open func enqueue(_ notification: Notification, postingStyle: PostingStyle, coalesceMask: NotificationCoalescing, forModes modes: [RunLoopMode]?) {
8584
var runloopModes: [RunLoopMode] = [.defaultRunLoopMode]
8685
if let modes = modes {
8786
runloopModes = modes

0 commit comments

Comments
 (0)