Pass data from one ViewController to another ViewController using NSUserdefaults

我怕爱的太早我们不能终老 提交于 2019-12-02 13:35:45

this is for storing

NSString  *verifyStatus=@"Y";

[[NSUserDefaults standardUserDefaults]setObject:verifyStatus forKey:@"verify_status"];
[[NSUserDefaults standardUserDefaults] synchronize];

for retrieving

 NSString *verify_status = [[NSUserDefaults standardUserDefaults]stringForKey:@"verify_status"];

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];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!