1

How do I move directories in cocoa?

Whenever I use NSFileManager I get an error.

NSFileManager* fileManager = [NSFileManager defaultManager];
[fileManager moveItemAtPath:[srcpath retain] toPath:[dstpath retain] error:&error];

I end up getting the error:

nameOfDir1 couldn't be moved to nameOfDir2

1
  • 1
    Why are you retaining those paths? Feb 5, 2011 at 2:03

1 Answer 1

1

Oh, I had to enter the directory name that I'm copying after the directory that I'm copying to.

1
  • Yes. NSFileManager won't imply the source directory's name if you leave out the name from the destination path; it sees that you passed a destination directory that already exists and rejects that. Feb 5, 2011 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.