ASNotificationCenter 1.0.1

ASNotificationCenter 1.0.1

测试测试过
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2017年3月

Alexey Anisimov 管理。



  • Aleksey Anisimov

示例

要运行示例项目,请克隆仓库,然后先从 Example 目录运行 pod install

用法

#import "ASNotificationCenter.h"

// append Notification listener for some class
-(void) someMethod{
    // ...
    [[ASNotificationCenter protectedCenter] addObserver:self selector:@selector(notificationOut:) name:@"someNotification" object:nil];
    // or use short declaration
    [_protectedCenter addObserver:self selector:@selector(notificationSecondOut:) name:@"someSecondNotification" object:nil];
    // ...
}

// Selectors

-(void) notificationOut:(ASNotification *) notification{
   // do something with ASNotification model (ASNotificationName name, id object, NSDictionary *userInfo)
   ...
}

-(void) notificationSecondOut:(ASNotification *) notification{
   // do something with ASNotification model (ASNotificationName name, id object, NSDictionary *userInfo)
   ...
   // you can also unsubscribe from ASNotificationCenter with notification.name
   [[ASNotificationCenter protectedCenter] removeObserver:self name:notification.name object:nil];
}

// Unsubscribe

-(void) dealloc{
// Unsubscribe all notification for this class
    [_protectedCenter removeObserver:self];
}

-(void) someUnsubscribe{
// Unsubscribe single notification for the name in this class
[[ASNotificationCenter protectedCenter] removeObserver:self name:@"someNotification" object:nil];
}

需求

安装

ASNotificationCenter 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "ASNotificationCenter"

作者

Aleksey Anisimov,[email protected]

许可证

ASNotificationCenter 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。