传值
一般指的是数据传递,有的是在某个类里面,有的是在类与类之间;
通知传值
通知传值就适用于类与类之间的数据传递.
代码示例
notiName
表示的是自定义的字符串,
注册通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(notiAction:) name:notiName object:nil];
发送通知
NSDictionary * dic = @{@”key”:@”value”};
[[NSNotificationCenter defaultCenter] postNotificationName:notiName object:dic];
移除通知
在-(void)dealloc{};中
[[NSNotificationCenter defaultCenter] removeObserver:self name:notiName object:nil];
小结:使用通知的时候,一定不要忘记通知使用的三步曲:注册通知,发送通知,移除通知.