/* 发通知 */
#define sendNotification(name,obj) [[NSNotificationCenter defaultCenter] postNotificationName:name object:obj];
//pod 'ReactiveCocoa', '2.5'
#import "ReactiveCocoa.h"
/* RAC收通知免移除 */
#define resiveNotification(name,block) [[[NSNotificationCenter defaultCenter]rac_addObserverForName:name object:nil]subscribeNext:^(id x) { NSNotification *user = x; block; }];
/* 子线程 */
#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
/* 主线程 */
#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)
// 调用
resiveNotification(name,
NSLog(@"%@",user.object);
)
sendNotification(name, @{@"1":@"2"});
/** 发通知 */
#define SendMessage(name,dic) [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:dic];
/** 收通知 */
#define ResiveMessage(name,DoSoming) [[NSNotificationCenter defaultCenter] addObserverForName:name object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { NSLog(@"%@",note); DoSoming }];
/** 移除通知 */
#define RemovoResiveMessage(name) [[NSNotificationCenter defaultCenter]removeObserver:self name:name object:nil];
// 调用
NSString *name = @"123";
ResiveMessage(name,
NSLog(@"%@",note.userInfo);
RemovoResiveMessage(name);// 移除监听
)
SendMessage(name, @{@"1":@"kewi"})