NSObject+BBANotification.h
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// NSObject+BBANotification.h
// BBAPods
//
// Created by 00 on 16/5/18.
// Copyright © 2016年 Baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BDPFoundationDefines.h"
/**
* 消息监听 扩展
* 详细介绍请看README-BBARuntime
*/
/**
@block
@brief 消息监听的 block
@param notification 传递的参数(NSNotification)
*/
typedef void(^BBANotificationBlock)(NSNotification *notification);
@interface NSObject (BBANotification)
/**
* @brief 为当前对象注册一个消息监听
*
* @param notificationName 待监听的消息
* @param sender 消息发送者
* @param block 监听到消息的回调
*
* @note 通过该方式注册的消息监听,会自动在 "当前对象" 或 "消息发送者" 释放之前,移除该消息监听
*/
- (void)bba_observeNotification:(NSString *)notificationName
sender:(id)sender
block:(BBANotificationBlock)block BDP_FOUNDATION_DEPRECATED("please use bdp_observeNotification:sender:block:");
- (void)bdp_observeNotification:(NSString *)notificationName
sender:(id)sender
block:(BBANotificationBlock)block;
/**
* @brief 手动移除指定的消息监听
*
* @param notificationName 监听的消息
*/
- (void)bba_removeNotification:(NSString *)notificationName BDP_FOUNDATION_DEPRECATED("please use bdp_removeNotification:");
- (void)bdp_removeNotification:(NSString *)notificationName;
@end