I\'m using this method to copy a file:
[fileManager copyItemAtPath:sourcePath toPath:targetPath error:&error];
I want to overwrite a fi
If you're not sure if the file exists, this works on swift 3+
try? FileManager.default.removeItem(at: item_destination)
try FileManager.default.copyItem(at: item, to: item_destination)
The first line fails and is ignored if the file doesn't already exist. If there's a exception durning the second line, it throws as it should.