when i enter a value in the iphone simulator and press the save button it only keeps the value until the simulator is running. and when i restart the simulator and press the load button it shows an earlier value entered by me.i.e, it is not able to keep the new value and keeps only old value.
i am using following loops for saving a file and loading a file.
-(IBAction) save{
NSUserDefaults *sinner=[NSUserDefaults standardUserDefaults];
[sinner setObject:serverIP.text forKey:@"load"];
NSUserDefaults *king=[NSUserDefaults standardUserDefaults];
[king setObject:noc.text forKey:@"save"];
}
-(IBAction) load {
NSUserDefaults *sinner=[NSUserDefaults standardUserDefaults];
NSString *tempstring =[sinner stringForKey:@"load"];
serverIP.text = [NSString stringWithFormat:tempstring];
NSUserDefaults *king=[NSUserDefaults standardUserDefaults];
NSString *tempstring1 =[king stringForKey:@"save"];
noc.text = [NSString stringWithFormat:tempstring1];
}
1 Answer