How to overwrite a folder using [NSFileManager defaultManager] when copying?

Viewed 7105

Using the line below,

[fileManager copyItemAtPath:sourcePath toPath:targetPath error:&error];

We can copy a folder but if the folder already exists it throws an exception "File Exists". In order to overwrite a single file, we can achieve it through the following lines:

NSData *myData = [NSData dataWithContentsOfURL:FileURL]; /fetch single file
[myData writeToFile:targetPath atomically:YES];

But I want to copy an already existing folder i.e, overwrite.

Edit : Simple Possibility , I can remove the items before copying them.

Please suggest any more possibilities.

4 Answers
Related