I used the below code for writing datas un the plist.
I got the error"Property list invalid for format".
I cant find the "Jsonapps.plist" under documents folder
I got the error"Property list invalid for format".
I cant find the "Jsonapps.plist" under documents folder
Code:
-(void)writeToList
{
NSLog(@"Usernameeeeeeee=%@",txtUsername.text);
NSLog(@"Passwordddddddd=%@",txtPassword.text);
//Write data in to plist
NSString *error;
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Jsonapps.plist"];
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict
format:NSPropertyListXMLFormat_v1_0
errorDescription:&error];
NSLog(@"plist dict=%@",plistDict);
NSLog(@"plistpath=%@",plistPath);
if (plistDict) {
NSLog(@"write file was found");
[plistDict setValue:txtPassword.text forKey:@"Password"];
[plistDict setValue:txtUsername.text forKey:@"Username"];
[plistDict writeToFile:plistPath atomically: YES];
}
else {
NSLog(error);
[error release];
}
}