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

# try()

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

## Declaration

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

## Return Value

Return Value true if the attempt to acquire the receiver was successful, otherwise false.

## Discussion

Discussion Raises NSGenericException if a file-system error occurs.

## See Also

### Related Documentation

- [unlock()](foundation/nsdistributedlock/unlock().md)
