IOS中NSNotification使用笔记

来源:互联网 发布:oracle关闭数据库命令 编辑:程序博客网 时间:2024/05/16 04:28

1 基本用法

添加观察(可能很多页面)


[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(changeIntlCode:)name:NOTIFICATION_SUCCESS_SELECT_INTLCODEobject:nil];


发出通知(可能只有一个页面)

[[NSNotificationCenterdefaultCenter] postNotificationName:NOTIFICATION_SUCCESS_SELECT_INTLCODEobject:niluserInfo:[NSDictionarydictionaryWithObject:model forKey:@"selectedIntlCodeModel"]];


在 dealloc中移除监听

[[NSNotificationCenter defaultCenter] removeObserver:self name:NOTIFICATION_SUCCESS_SELECT_INTLCODE object:nil];




0 1
原创粉丝点击