BCNotificationCentre 1.1.0

BCNotificationCentre 1.1.0

测试已测试
语言语言 SwiftSwift
许可证 Apache 2
发布最后发布Sep 2016
SPM支持 SPM

Romain Francez 维护。



BCNotificationCentre

添加观察者并发送带优先级和类型值的通知。

  • [x]📱iOS 8.0+
  • [x]💻Mac OS X 10.9+
  • [x]⌚️watchOS 2.0+

安装

Version Build Status

CocoaPods

BCNotificationCentre 通过 CocoaPods 提供使用。

pod 'BCNotificationCentre'

快速入门

添加通知观察者

BCNotificationCentre.defaultCentre.addObserverForName("notificationName") { (notification: BCNotification<String>) -> Void in
  // Do something with the notification
}

发布通知

let notification = BCNotification(name: "notificationName", value: "the value associated")
BCNotificationCentre.defaultCentre.postNotification(notification)

类型通知

通知是分类型的

BCNotificationCentre.defaultCentre.addObserverForName("notificationName") { (notification: BCNotification<String>) -> Void in
  // Do something with the notification with the associated string value
}

BCNotificationCentre.defaultCentre.addObserverForName("notificationName") { (notification: BCNotification<Int>) -> Void in
  // Will not be called as the posted notification as an associated string value
}

let notification = BCNotification(name: "notificationName", value: "the value associated")
BCNotificationCentre.defaultCentre.postNotification(notification)

优先通知

通知是优先级较高的

BCNotificationCentre.defaultCentre.addObserverForName("notificationName", priority: .Low) { (notification: BCNotification<String>) -> Void in
  // This will be called after the normal priority notification
}

BCNotificationCentre.defaultCentre.addObserverForName("notificationName", priority: .Normal) { (notification: BCNotification<String>) -> Void in
  // This will be called first
}

let notification = BCNotification(name: "notificationName", value: "the value associated")
BCNotificationCentre.defaultCentre.postNotification(notification)

许可证

BCNotificationCentre 可在 Apache License, Version 2.0 下使用。请参阅 LICENSE 文件获取更多信息。