NSObject+BBANotification.h 1.5 KB
//
//  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