消息中心传值总共分为三部分:
第一步:
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeAction:) name:@"CHANGEARRAY" object:Nil];
分析:
defaultCenter,消息中心只有一个,通过类方法获取它的单例
addObserver:发出者 一般为self
name : 暗号 一般为大写
object : nil 为公共的
第二步:
-(void)changeAction:(NSNotification *)noti
{
//接受传回来的参数 然后接受
NSDictionary * dic = [noti userInfo];
//然后执行其他的方法
}
第三步:
//进行传值
[[NSNotificationCenter defaultCenter]postNotificationName:@"CHANGEARRAY" object:Nil userInfo:dic];
分析:
postNotificationName:对暗号 与前面暗号一致
userInfo : 想传得参数