iOS通知如何传值?

    

    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);

}


你可能感兴趣的:(iOS通知如何传值?)