Instance Method


Duplicates the specified URLS asynchronously in the same manner as the Finder.


- (void)duplicateURLs:(NSArray<NSURL *> *)URLs completionHandler:(void (^)(NSDictionary<NSURL *,NSURL *> *newURLs, NSError *error))handler;



An array of NSURL objects representing the files to duplicate. This parameter must not be nil.


The completion handler block object to call when the operation completes. You may specify nil for this parameter. If this parameter is not nil, you must call the duplicateURLs:completionHandler: method from a block running on an active dispatch queue; your completion handler block is subsequently executed on the same dispatch queue.

This block takes two parameters:


A dictionary parameter whose keys and values are NSURL objects. Each key is a URL from the URLs parameter. The value of each key is a URL representing the location of the duplicated file. If this method could not duplicate a file, the corresponding URL is not included in the dictionary.


If the operation succeeded for every file, this parameter is nil. If the operation failed for one or more files, the parameter contains an error object describing the overall result of the operation in a manner suitable for presentation to the user.


This method may cause a progress indicator, or other user interface element, to be shown by the Finder.

In OS X v10.6, this method requires that the main run loop be run in a common mode. It is safe to call this method from any thread of your app.

See Also

Manipulating Files

- recycleURLs:completionHandler:

Moves the specified URLs to the trash in the same manner as the Finder.

- performFileOperation:source:destination:files:tag:

Performs a file operation on a set of files in a particular directory.

- activateFileViewerSelectingURLs:

Activates the Finder, and opens one or more windows selecting the specified files.

- selectFile:inFileViewerRootedAtPath:

Selects the file specified by fullPath.


These constants specify different types of file operations used by performFileOperation:source:destination:files:tag:.

File Types

These constants specify different types of files returned by the getInfoForFile:application:type: method.