I have two UITextField
- password
These two field values are stored in a NSMutableDictionary
call userData
. Now i want to save these two field values in a file, so that the records keep there and i can restore this record to check user login correctly. Here i want to accomplish that, but not working.
My code :
-(void) saveRegistrationData
{
userData = [[NSMutableDictionary alloc]
initWithObjects:[[NSMutableArray alloc] initWithObjects:@"123456", nil]
forKeys:[[NSMutableArray alloc] initWithObjects:@"admin@gmail.com", nil]];
[userData setObject:passwordTextField.text forKey:emailTextField.text];
NSString *savePath = [@"/MediaFiles/Documents/" stringByExpandingTildeInPath];
[userData writeToFile: savePath atomically: YES];
//[userData writeToFile:@"MediaFiles/Documents/" atomically:YES];
for (id key in userData)
{
NSLog(@"%@ is for %@", key, [userData objectForKey:key]);
}
}
I think the path
is not setting correctly. If any one similar with the solution, please share with me. Thanks in advanced. Have a good day.