Pass data from one ViewController to another ViewController using NSUserdefaults

前端 未结 2 1981
失恋的感觉
失恋的感觉 2021-01-29 15:07

I need to data from one ViewController to another ViewController Here I\'ve Multiple Textfields in first ViewController then it will passed the SecondViewController in Whatever

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-29 15:56

    You can also use property for this... Because It's easy ..

    Make NSMutableDictionary type Property in another ViewController and send from first ViewController

    Make this type property in your second viewcontroller

      @property (nonatomic,retain) NSMutableDictionary *textFieldDataDic;
    

    and send data from first viewcontroller like this

    NSMutableDictionary *textFieldData = [[NSMutableDictionary alloc]init];
     [textFieldData setValue:textfield1 forKeyPath:@"textF1"];
     [textFieldData setValue:textfield2 forKeyPath:@"textF2"];
    
    ViewController *secondView = [[ViewController alloc]init];
    secondView.textFieldDataDic = textFieldData;
    [self.navigationController pushViewController:secondView animated:YES];
    

提交回复
热议问题