---
title: "init(path:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsdistributedlock/init(path:)"
---

# init(path:)

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

## Declaration

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

## Parameters

- `path`: All of path up to the last component itself must exist. You can use doc://com.apple.foundation/documentation/Foundation/FileManager to create (and set permissions) for any nonexistent intermediate directories.

## Return Value

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

## Discussion

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