Search code examples
objective-ciosnsfilemanager

Moving the contents of a directory to another directory (iOS)


When a user uses my app without logging on I store all the files they create in a directory called default_dir(which contains files and sub-dirs). When they do eventually login in I need to move the files from default_dir to a newly created dir called user_name.

That gives me 2 options.

Rename default_dir to user_name (I can't see anything on NSFilemanager to indicate this is possible).

Or try to somehow copy all the files and dirs into a newly created dir, user_name.

Can you advise how best to proceed in accomplishing this please?

Many Thanks, -Code


Solution

  • Did you try NSFileManager's -moveItemAtURL:toURL:error: ?