NSNotificationCenter通知

NSNotificationCenter通知,用userInfo实现 

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"];

}

你可能感兴趣的:(NSNotificationCenter通知)