JKNoticationHelper 0.1.3

JKNoticationHelper 0.1.3

Maintained by jack.



  • By
  • xindizhiyin2014

JKNoticationHelper

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

summary

this tool help you to use notificaion easily,you don't need to care to removeObserver. and easy to use.

Requirements

Installation

JKNoticationHelper is available through CocoaPods. To install it, simply add the following line to your Podfile:

OC:

pod 'JKNoticationHelper'

swift:

pod 'JKNoticationHelper_Swift'

how to use

1) conform the JKFastNotificationProtocol

class ViewController: UIViewController,JKFastNotificationProtocol {
}
2) add Observer
jk_observeNotificaion(name: "aaaaa") { notification in
            print("hahah")
        }

3) post Observer

jk_postNotification(notificationName: "aaaaa")

demo code

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.
    }

}

Author

xindizhiyin2014, [email protected]

License

JKNoticationHelper is available under the MIT license. See the LICENSE file for more info.