---
title: "lock(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocument/lock(_:)"
---

# lock(_:)

Locks the document in response to the user choosing the Lock menu item.

## Declaration

```swift
@IBAction func lock(_ sender: Any?)
```

## Parameters

- `sender`: The control sending the message.

## Discussion

Discussion This is the action of the Lock menu item in a document-based app. This action method invokes the lock(completionHandler:) method by default.

## See Also

### Locking the Document

- [unlock(_:)](appkit/nsdocument/unlock(_:).md)
- [lock(completionHandler:)](appkit/nsdocument/lock(completionhandler:)-6zuhh.md)
- [lock(completionHandler:)](appkit/nsdocument/lock(completionhandler:)-161qv.md)
- [unlock(completionHandler:)](appkit/nsdocument/unlock(completionhandler:)-8p8zd.md)
- [unlock(completionHandler:)](appkit/nsdocument/unlock(completionhandler:)-6m7rh.md)
- [isLocked](appkit/nsdocument/islocked.md)
