O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

File Operations

NSFileManager also abstracts out a number of common file operations, such as copying, moving, removing, and linking items. As expected, there are two API families: one using string paths and the other using URLs.

Path operations

You can use the following methods to copy, move, (hard) link, and remove files and directories:

- (BOOL) copyItemAtPath: (NSString *) srcPath  toPath: (NSString *) dstPath
                  error: (NSError **) error;

- (BOOL) moveItemAtPath: (NSString *) srcPath  toPath: (NSString *) dstPath
                  error: (NSError **) error;

- (BOOL) linkItemAtPath: (NSString *) srcPath  toPath: (NSString *) dstPath 
                  error: (NSError **) error;

- (BOOL) removeItemAtPath: (NSString *) path 
                    error: (NSError **) error;

These methods will potentially ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required