您的位置:首页 > 移动开发 > IOS开发

iOS通知如何传值?

2015-12-23 17:46 363 查看
ViewController *viewVC = [[ViewController
alloc]
init];

[[NSNotificationCenter
defaultCenter] addObserver:viewVC
selector:@selector(sendVaue:)
name:@"showmessage"
object:nil];

NSDictionary *dict = [[NSDictionary
alloc] initWithObjectsAndKeys:@"user",@"type",
nil];

[[NSNotificationCenter
defaultCenter] postNotificationName:@"showmessage"
object:dict];

[self.navigationController
pushViewController:viewVC animated:YES];

在ViewController.m 接收值

-(void)sendVaue:(NSNotification *)notification{

id message = [notification
object];

NSLog(@"sendVaue
- message: %@",message);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: