---
title: "lock(before:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsrecursivelock/lock(before:)"
---

# lock(before:)

Attempts to acquire a lock before a given date.

## Declaration

```swift
func lock(before limit: Date) -> Bool
```

## Parameters

- `limit`: The time before which the lock should be acquired.

## Return Value

Return Value true if the lock is acquired before limit, otherwise false.

## Discussion

Discussion The thread is blocked until the receiver acquires the lock or limit is reached.

## See Also

### Related Documentation

- [Threading Programming Guide](apple-archive/documentation/Cocoa/Conceptual/Multithreading/Introduction.md)

### Acquiring a Lock

- [try()](foundation/nsrecursivelock/try().md)
