iOS消息NSNotificationCenter通知传值到不同界面

首先,先注册一个消息通知:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *jsonDict = [_temp objectAtIndex:indexPath.row];
   [[NSNotificationCenter defaultCenter]postNotificationName:@"zixun" object:nil userInfo:@{@"cellKey":jsonDict[@"title"]}];
    [WTSDK Ins].giftStr = jsonDict[@"title"];
    NSLog(@"%@打印的pppppp=====",[WTSDK Ins].giftStr);
    [self cellEvent];
}

然后,另一个界面接收传来的通知:

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(editBtn:) name:@"zixun" object:nil];

实现方法:

- (void)editBtn:(NSNotification *)sender{
 self.content_Value = sender.userInfo[@"cellKey"];
 NSLog(@"%@self.content_Value==",self.content_Value);
}

这样子就可以了

猜你喜欢

转载自blog.csdn.net/xiao19911130/article/details/107878392
今日推荐