---
title: "linkPath:toPath:handler:"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsfilemanager/linkpath:topath:handler:"
---

# linkPath:toPath:handler:

Creates a link from a source to a destination.

## Declaration

```occ
- (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

Return Value true if the link operation is successful. If the operation is not successful, but the handler method fileManager(_:shouldProceedAfterError:) returns true, also returns true. Otherwise returns false.

## Discussion

Discussion The handler callback mechanism is similar to delegation. NSFileManager sends fileManager(_:willProcessPath:) when it begins a copy, move, remove, or link operation. It sends 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:) instead.

## See Also

### Related Documentation

- [linkItem(at:to:)](foundation/filemanager/linkitem(at:to:).md)
- [moveItem(atPath:toPath:)](foundation/filemanager/moveitem(atpath:topath:).md)
- [createSymbolicLink(atPath:withDestinationPath:)](foundation/filemanager/createsymboliclink(atpath:withdestinationpath:).md)
- [copyItem(atPath:toPath:)](foundation/filemanager/copyitem(atpath:topath:).md)
- [removeItem(atPath:)](foundation/filemanager/removeitem(atpath:).md)

### Deprecated Methods

- [copyPath:toPath:handler:](foundation/nsfilemanager/copypath:topath:handler:.md)
- [movePath:toPath:handler:](foundation/nsfilemanager/movepath:topath:handler:.md)
- [removeFileAtPath:handler:](foundation/nsfilemanager/removefileatpath:handler:.md)
- [changeFileAttributes(_:atPath:)](foundation/filemanager/changefileattributes(_:atpath:).md)
- [fileAttributes(atPath:traverseLink:)](foundation/filemanager/fileattributes(atpath:traverselink:).md)
- [fileSystemAttributes(atPath:)](foundation/filemanager/filesystemattributes(atpath:).md)
- [directoryContents(atPath:)](foundation/filemanager/directorycontents(atpath:).md)
- [createDirectory(atPath:attributes:)](foundation/filemanager/createdirectory(atpath:attributes:).md)
- [createSymbolicLink(atPath:pathContent:)](foundation/filemanager/createsymboliclink(atpath:pathcontent:).md)
- [pathContentOfSymbolicLink(atPath:)](foundation/filemanager/pathcontentofsymboliclink(atpath:).md)
- [fileManager(_:shouldProceedAfterError:)](objectivec/nsobject-swift.class/filemanager(_:shouldproceedaftererror:).md)
- [fileManager(_:willProcessPath:)](objectivec/nsobject-swift.class/filemanager(_:willprocesspath:).md)
