RENNotificationCenter 0.0.5

RENNotificationCenter 0.0.5

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2016年3月

REN-LEI维护。



  • 作者
  • renlei

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

特性

  • 利用iOS的动态性实现自动释放通知,当持有类销毁时,自动释放注册通知
  • 使用block作为事件触发的回调,简洁明了
  • 支持系统的所有通知,并转发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"];

安装

源文件

直接导入源文件。

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

感谢

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

许可证

基于MIT协议