<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSDistributedLock/init(path:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDistributedLock(im)initWithPath:"
  },
  "title" : "init(path:)"
}
-->

# init(path:)

Initializes an `NSDistributedLock` object to use as the lock the file-system entry specified by a given path.

```
init?(path: String)
```

## Parameters

`path`

All of `path` up to the last component itself must exist. You can use [`FileManager`](/documentation/Foundation/FileManager) to create (and set permissions) for any nonexistent intermediate directories.

## Return Value

An `NSDistributedLock` object initialized to use as the locking object the file-system entry specified by `path`.

## Discussion

For applications to use the lock, `path` must be accessible to—and writable by—all hosts on which the applications might be running.

## See Also

[`+  lockWithPath:`](/documentation/Foundation/NSDistributedLock/lockWithPath:)

Returns an `NSDistributedLock` object initialized to use as the locking object the file-system entry specified by a given 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)