How do you create custom notifications in Swift 3?

前端 未结 13 696
自闭症患者
自闭症患者 2020-12-04 09:07

In Objective-C, a custom notification is just a plain NSString, but it\'s not obvious in the WWDC version of Swift 3 just what it should be.

13条回答
  •  借酒劲吻你
    2020-12-04 09:14

    if you use string-only custom notifications, there's no reason to extend any classes but String

        extension String {
            var notificationName : Notification.Name{
                return Notification.Name.init(self)
            }
        }
    

提交回复
热议问题