您的位置:首页 > 其它

NSNotificationCenter

2016-05-19 09:32 288 查看
@interface NSNotificationCenter : NSObject

+ (NSNotificationCenter *)defaultCenter;


//发出通知
//[NSNotificationCenter defaultCenter]调用
//aName:通知的名字
//aUserInfo:将参数以字典形式封装
- (void)postNotificationName:(NSString *)aName object:(nullable id)anObject userInfo:(nullable NSDictionary *)aUserInfo;

//收到通知
//[NSNotificationCenter defaultCenter]调用
//aName:通知的名字
//aSelector收到通知之后的动作
- (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable NSString *)aName object:(nullable id)anObject;

//notification.userInfo里面有参数
- (void)aSelector(NSNotification *)notification {
//@property (nullable, readonly, copy) NSDictionary *userInfo;

}


移除通知(必须移除参数)

//[NSNotificationCenter defaultCenter]调用

- (void)removeObserver:(id)observer;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: