I\'m using this method to copy a file:
[fileManager copyItemAtPath:sourcePath toPath:targetPath error:&error];
I want to overwrite a fi
You'd want to do an atomic save in this case, which would be best achieved by using NSData or NSString's writeToFile:atomically: methods (and their variants):
NSData *myData = ...; //fetched from somewhere
[myData writeToFile:targetPath atomically:YES];
Or for an NSString:
NSString *myString = ...;
NSError *err = nil;
[myString writeToFile:targetPath atomically:YES encoding:NSUTF8StringEncoding error:&err];
if(err != nil) {
//we have an error.
}