I want to save the token from from the server into a plist. I am not sure If I have to create a plist firs or it can automatically get created with the following code in my Document directroy. However, I am not able to create a plist and write my dictionary into it. Here is my code
-(void)writeToPlist:(NSString*)value forkey:(NSString *)key
{
NSLog(@"Write plist here");
//NSError *error;
NSArray *paths=NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory=[paths objectAtIndex:0];
NSString* path=[documentDirectory stringByAppendingFormat:@"Util.plist"];
NSLog(@"The path is %@",path);
NSFileManager *fileManager=[NSFileManager defaultManager];
NSMutableDictionary *data;
if(![fileManager fileExistsAtPath:path])
{
path=[[NSBundle mainBundle]pathForResource:@"Util" ofType:@"plist"];
}
[data setObject:value forKey:key];
[data writeToFile:path atomically:YES];//will it create the plist?
}