天天看點

通知中心 NSNotification

1. 定義一個方法

-(void) update{} 

2. 對象注冊,并關連消息

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

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

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

通知中心可以跨對象的。