简单实现KVO传值
其实KVO的传值核心就是一个传一个接
那么代码如下
传值:
[[NSNotificationCenter defaultCenter]postNotificationName:@“这里是关键字”object:nil userInfo:这里是dic类型的数据];
接值:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(kvoData:) name: @“这里是关键字” object:nil];
- (void) kvoData:(NSNotification *)notification{
Notification:这个就是传过来的字典
}
都写完之后别忘了移除呀
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
干货就是这么简单,点个赞再走呀亲!!!