标签:消息 tor observer obj nsstring cat userinfo string object
1.发送消息
1 NSNotification *notification = [NSNotification notificationWithName:@"selectPosition" object:nil userInfo:@"codeABC" forKey:@"code"]; 2 [[NSNotificationCenter defaultCenter]postNotification:notification];
2.接收消息
1 - (void)viewDidLoad { 2 [super viewDidLoad]; 3 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(selectPosition:) name:@"selectPosition" object:nil]; 4 } 5 6 - (void)selectPosition:(NSNotification *)notification 7 { 8 NSString *code = [notification.userInfo objectForKey:@"code"]; 9 }
标签:消息 tor observer obj nsstring cat userinfo string object
原文地址:https://www.cnblogs.com/luoluosha/p/11679967.html