天天看点

通知中心 NSNotification

1. 定义一个方法

-(void) update{} 

2. 对象注册,并关连消息

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(update) name:@"update" object:nil] 

3. 在要发出通知消息的地方

[[NSNotificationCenter defaultCenter] postNotificationName:@"update" object:nil];

通知中心可以跨对象的。