Hi guys,
I try to write contents of a dictionary to a file. I use the following code. The paths checkout to be valid. But the functions returns a no.
Could it be that the file Storage.dat not is created yet.. Because i can't access my device filesystem. On the simulator it also doesn't work.
What am i doing wrong; i have the following code:
Please help
I try to write contents of a dictionary to a file. I use the following code. The paths checkout to be valid. But the functions returns a no.
Could it be that the file Storage.dat not is created yet.. Because i can't access my device filesystem. On the simulator it also doesn't work.
What am i doing wrong; i have the following code:
Code:
- (int) saveData:(NSString*)EntityName :(NSString*)EntityData
{
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
NSString* location = [[NSString alloc] initWithString:[documentsDirectory stringByAppendingString:@"/Storage.dat"]];
NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithContentsOfFile: location];
[data setObject:EntityData forKey: EntityName];
if(![data writeToFile: location atomically: YES])
return 0;
return 1;
}
Please help