---
title: try()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/nsrecursivelock/try()
---

# try()

Attempts to acquire a lock, and immediately returns a Boolean value that indicates whether the attempt was successful.

## Declaration

```swift
func `try`() -> Bool
```

## Return Value

Return Value true if successful, otherwise false.

## See Also

### Acquiring a Lock

- [lock(before:)](foundation/nsrecursivelock/lock(before:).md)
