NSNotificationCenter通知,用userInfo实现

来源:互联网 发布:喜马拉雅fm连不上网络 编辑:程序博客网 时间:2024/06/05 23:30
1、发通知
NSDictionary *myDictionary = [NSDictionary dictionaryWithObject:@"sendValue" forKey:@"sendKey"];[[NSNotificationCenter defaultCenter] postNotificationName:@"myNotice" object:nil userInfo:myDictionary];


2、接受通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noticeMethod:) name:@"myNotice" object:nil];

3、调用方法,接受信息。
- (void)noticeMethod:(NSNotification *)notification{NSString *getsendValue = [[notification userInfo] valueForKey:@"sendKey"];}


0 0
原创粉丝点击