I'm in trouble with paths, relative paths, NSBundle and all the path/file related operations :)
While i run the simulator everthing goes right but all the file changes are not permanent, so everytime i run my app i have to repeat the initial setup of my app.
The question: What is the proper way to read and write files (from resource dir) and make all the file changes permanent (updated into the project folder) ?
Thanks
EDIT: i write a simple method to do it, it's correct ?
-(NSString *) getPath:(NSString *)forResource
{
NSString *pathRes, *docPath, *destPath;
NSArray *foundPaths;
NSFileManager *fs = [[NSFileManager alloc] init];
foundPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
docPath = [foundPaths objectAtIndex:0];
destPath = [[NSString stringWithFormat:@"%@/%@",docPath,forResource] stringByStandardizingPath];
if(![fs fileExistsAtPath:destPath])
{
pathRes = [[NSBundle mainBundle] pathForResource:forResource ofType:nil];
[fs copyItemAtPath:pathRes toPath:destPath error:nil];
}
return destPath;
}