Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix Notification API signatures to match Darwin" #1156

Merged
merged 1 commit into from Aug 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 4 additions & 12 deletions Foundation/NSNotification.swift
Expand Up @@ -23,7 +23,7 @@ open class NSNotification: NSObject, NSCopying, NSCoding {
}
}

private(set) open var name: NSNotification.Name
private(set) open var name: Name

private(set) open var object: Any?

Expand All @@ -33,12 +33,8 @@ open class NSNotification: NSObject, NSCopying, NSCoding {
/* 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: NSNotification.Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) {
public init(name: Name, object: Any?, userInfo: [AnyHashable : Any]? = nil) {
self.name = name
self.object = object
self.userInfo = userInfo
Expand Down Expand Up @@ -173,11 +169,7 @@ open class NotificationCenter: NSObject {
}
}

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) {
open func post(name aName: Notification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable : Any]? = nil) {
let notification = Notification(name: aName, object: anObject, userInfo: aUserInfo)
post(notification)
}
Expand All @@ -196,7 +188,7 @@ open class NotificationCenter: NSObject {
})
}

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

let newObserver = NSNotificationReceiver()
Expand Down
2 changes: 1 addition & 1 deletion Foundation/Notification.swift
Expand Up @@ -18,7 +18,7 @@ public struct Notification : ReferenceConvertible, Equatable, Hashable {
public typealias ReferenceType = NSNotification

/// A tag identifying the notification.
public var name: Notification.Name
public var name: Name

/// An object that the poster wishes to send to observers.
///
Expand Down
5 changes: 2 additions & 3 deletions Foundation/NotificationQueue.swift
Expand Up @@ -76,12 +76,11 @@ open class NotificationQueue: NSObject {
removeRunloopObserver(self.asapRunloopObserver)
}

open func enqueue(_ notification: Notification, postingStyle: NotificationQueue.PostingStyle) {
open func enqueue(_ notification: Notification, postingStyle: PostingStyle) {
enqueue(notification, postingStyle: postingStyle, coalesceMask: [.onName, .onSender], forModes: nil)
}

open func enqueue(_ notification: Notification, postingStyle: NotificationQueue.PostingStyle,
coalesceMask: NotificationQueue.NotificationCoalescing, forModes modes: [RunLoopMode]?) {
open func enqueue(_ notification: Notification, postingStyle: PostingStyle, coalesceMask: NotificationCoalescing, forModes modes: [RunLoopMode]?) {
var runloopModes: [RunLoopMode] = [.defaultRunLoopMode]
if let modes = modes {
runloopModes = modes
Expand Down