<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.5.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSFileManager/linkPath:toPath:handler:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)linkPath:toPath:handler:"
  },
  "title" : "linkPath:toPath:handler:"
}
-->

# linkPath:toPath:handler:

Creates a link from a source to a destination.

```
- (BOOL) linkPath:(NSString *) src toPath:(NSString *) dest handler:(id) handler;
```

## Parameters

`src`

A path that identifies a source file or directory.

    The file, link, or directory specified by     `source`     must exist.

`dest`

A path that identifies a destination file or directory.

    The destination should not yet exist. The destination path must end in a filename; there is no implicit adoption of the source filename.

`handler`

An object that responds to the callback messages <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:willProcessPath:)> and <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)>. You can specify `nil` for `handler`; if you do so and an error occurs, the method automatically returns <doc://com.apple.documentation/documentation/Swift/false>.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the link operation is successful. If the operation is not successful, but the handler method <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)> returns <doc://com.apple.documentation/documentation/Swift/true>, also returns <doc://com.apple.documentation/documentation/Swift/true>. Otherwise returns <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

The handler callback mechanism is similar to delegation. `NSFileManager` sends <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:willProcessPath:)> when it begins a copy, move, remove, or link operation. It sends <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)> when it encounters any error in processing

### Special Considerations

Because this method does not return error information, it has been deprecated as of OS X v10.5. Use [`removeItem(atPath:)`](/documentation/Foundation/FileManager/removeItem(atPath:)) instead.

## See Also

[`func linkItem(at: URL, to: URL) throws`](/documentation/Foundation/FileManager/linkItem(at:to:))

Creates a hard link between the items at the specified URLs.

[`func moveItem(atPath: String, toPath: String) throws`](/documentation/Foundation/FileManager/moveItem(atPath:toPath:))

Moves the file or directory at the specified path to a new location synchronously.

[`func createSymbolicLink(atPath: String, withDestinationPath: String) throws`](/documentation/Foundation/FileManager/createSymbolicLink(atPath:withDestinationPath:))

Creates a symbolic link that points to the specified destination.

[`func copyItem(atPath: String, toPath: String) throws`](/documentation/Foundation/FileManager/copyItem(atPath:toPath:))

Copies the item at the specified path to a new location synchronously.

[`func removeItem(atPath: String) throws`](/documentation/Foundation/FileManager/removeItem(atPath:))

Removes the file or directory at the specified path.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)