通知中心传值:
controller1:
-(void)btnClick:(UIButton *)btn
{
OneViewController *oVC = [[OneViewController alloc]init];
[self.navigationController pushViewController:oVC animated:YES];
//注册接收的通知中心
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
//接收通知
[center addObserver:self selector:@selector(receiveNotification:) name:@"notification" object:nil];
}
-(void)receiveNotification:(NSNotification *)notification
{
self.textField.text = [notification.userInfo valueForKey:@"text"];
}
controller2:
@property(strong,nonatomic)NSDictionary *dic;
_dic = @{@"text":self.onetextField.text};
//注册通知中心
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
//发送通知
[center postNotificationName:@"notification" object:nil userInfo:_dic];