Latest 0.0.5
Homepage https://github.com/REN-LEI/RENNotificationCenter
License MIT
Platforms ios 6.0, requires ARC
Authors

RENNotificationCenter是一款非常小巧轻量的基于NSNotificationCenter的封装,用于简化 iOS 开发中的发布订阅模式。

特性

  • 利用iOS动态性实现自动释放通知,当持有类销毁时,自动释放注册通知
  • 使用blcok的方式作为事件触发的回调,简洁明了
  • 支持系统的所有通知,并转发userInfo字段

[self.notification rl_subscribe:UIApplicationDidEnterBackgroundNotification block:^(RENEvent *event) {
    NSLog(@"eventName = %@",event.name);
}];

[self.notification rl_subscribe:@"CustomEventName" block:^(RENEvent *event) {
    NSLog(@"eventName = %@",event.name);
}];

[self.notification rl_publish:@"CustomEventName" userInfo:@"hello"];

[self.notification rl_unsubscribe:@"CustomEventName"];

安装

CocoaPods

  • Podfile 里添加以下依赖:
pod 'RENNotificationCenter', '~> 0.0.4'
  • 运行 pod install

源文件

直接导入源文件。

  • 下载最新代码
  • 导入 RENNotificationCenter.hRENNotificationCenter.m

感谢

本人通过阅读Facebook开源的KVOController源码后,基于其思想实现了RENNotificationCenter

License

基于 MIT 协议

Latest podspec

{
    "name": "RENNotificationCenter",
    "version": "0.0.5",
    "summary": "An easy way to use notification",
    "homepage": "https://github.com/REN-LEI/RENNotificationCenter",
    "license": "MIT",
    "authors": {
        "renlei": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/REN-LEI/RENNotificationCenter.git",
        "tag": "0.0.5"
    },
    "source_files": "RENNotificationCenter/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This