Swift 3:NSNotification与通知

时间:2016-11-20 23:38:54

标签: swift3

在Swift 3中,NotificationNSNotification之间有什么区别?

具体来说,在Notification struct中,ReferenceType类型为NSNotification。 ReferenceType是如何在这里使用的?

public struct Notification : ReferenceConvertible, Equatable, Hashable {

    public typealias ReferenceType = NSNotification
    ...
}

1 个答案:

答案 0 :(得分:1)

Notification是围绕NSNotification的结构包装器。您可以使用as来完成两者之间的桥接,这是ReferenceConvertible所做的。