通知传值没有想象中的那么难,很简单就3步:post
1.在要传值的地方post:spa
[[NSNotificationCenter defaultCenter] postNotificationName:kMaxDidNotification object:self userInfo:@{@"max":maxValue}];server
把须要传的数据写在字典里,本身设置键值对就能够,通知名也是本身设置的。rem
2.在须要接收数据的地方添加观察者:io
3.通知用了以后记得removeobject
__block id successObserver =[[NSNotificationCenter defaultCenter]addObserverForName:kMaxDidNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * note) {queue
maxLabel.text = note.userInfo[@"max"];数据
//使用传过来的数据co
} [[NSNotificationCenter defaultCenter]removeObserver:successObserver];字典
}】;