Permanent file changes on iPhone simulator
<p>I'm in trouble with paths, relative paths, NSBundle and all the path/file related operations :)</p>

<p>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.</p>

<p><strong>The question:</strong>
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) ?</p>

<p>Thanks</p>

<p>EDIT: i write a simple method to do it, it's correct ?</p>

<pre><code>-(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;
}
</code></pre>
