@@ -23,7 +23,7 @@ open class NSNotification: NSObject, NSCopying, NSCoding {
23
23
}
24
24
}
25
25
26
- private( set) open var name : Name
26
+ private( set) open var name : NSNotification . Name
27
27
28
28
private( set) open var object : Any ?
29
29
@@ -33,8 +33,12 @@ open class NSNotification: NSObject, NSCopying, NSCoding {
33
33
/* do not invoke; not a valid initializer for this class */
34
34
fatalError ( )
35
35
}
36
+
37
+ public convenience init ( name: NSNotification . Name , object: Any ? ) {
38
+ self . init ( name: name, object: object, userInfo: nil )
39
+ }
36
40
37
- public init ( name: Name , object: Any ? , userInfo: [ AnyHashable : Any ] ? = nil ) {
41
+ public init ( name: NSNotification . Name , object: Any ? , userInfo: [ AnyHashable : Any ] ? = nil ) {
38
42
self . name = name
39
43
self . object = object
40
44
self . userInfo = userInfo
@@ -169,7 +173,11 @@ open class NotificationCenter: NSObject {
169
173
}
170
174
}
171
175
172
- open func post( name aName: Notification . Name , object anObject: Any ? , userInfo aUserInfo: [ AnyHashable : Any ] ? = nil ) {
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 ) {
173
181
let notification = Notification ( name: aName, object: anObject, userInfo: aUserInfo)
174
182
post ( notification)
175
183
}
@@ -188,7 +196,7 @@ open class NotificationCenter: NSObject {
188
196
} )
189
197
}
190
198
191
- open func addObserver( forName name: Notification . Name ? , object obj: Any ? , queue: OperationQueue ? , usingBlock block: @escaping ( Notification ) -> Void ) -> NSObjectProtocol {
199
+ open func addObserver( forName name: NSNotification . Name ? , object obj: Any ? , queue: OperationQueue ? , using block: @escaping ( Notification ) -> Void ) -> NSObjectProtocol {
192
200
let object = NSObject ( )
193
201
194
202
let newObserver = NSNotificationReceiver ( )
0 commit comments