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 }

 

相关文章:

  • 2021-11-17
  • 2022-01-09
  • 2021-09-25
  • 2022-02-26
  • 2022-01-01
  • 2021-12-03
  • 2021-08-20
  • 2022-12-23
猜你喜欢
  • 2021-07-10
  • 2021-09-11
  • 2022-12-23
  • 2021-05-26
  • 2021-10-17
  • 2021-10-22
相关资源
相似解决方案