JKNoticationHelper
示例
要运行示例项目,请克隆存储库,并首先从 Example 目录运行 pod install
概括
这个工具可以帮助您轻松使用通知,您无需关心移除观察者。使用简单。
需求
安装
JKNotificationHelper 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中
pod 'JKNoticationHelper'
pod 'JKNoticationHelper_Swift'
class ViewController: UIViewController,JKFastNotificationProtocol {
}
jk_observeNotificaion(name: "aaaaa") { notification in
print("hahah")
}
jk_postNotification(notificationName: "aaaaa")
import UIKit
import JKNoticationHelper_Swift
class ViewController: UIViewController,JKFastNotificationProtocol {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let button:UIButton = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 60))
button.backgroundColor = .red
self.view.addSubview(button)
button.center = self.view.center
button.addTarget(self, action: #selector(buttonClicked), for:.touchUpInside)
jk_observeNotificaion(name: "aaaaa") { notification in
print("hahah")
}
}
@objc func buttonClicked() ->Void {
let person = Person()
jk_postNotification(notificationName: "aaaaa")
let vc:BViewController = BViewController()
present(vc, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
作者
xindizhiyin2014, [email protected]
许可
JKNoticationHelper 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。