---
title: tryLock()
framework: coredata
role: symbol
role_heading: Instance Method
path: coredata/nsmanagedobjectcontext/trylock()
---

# tryLock()

Attempts to acquire a lock.

## Declaration

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

## Return Value

Return Value true if a lock was acquired, false otherwise.

## Discussion

Discussion This method returns immediately after the attempt to acquire a lock.

## See Also

### Deprecated instance methods

- [init(concurrencyType:)](coredata/nsmanagedobjectcontext/init(concurrencytype:).md)
- [init()](coredata/nsmanagedobjectcontext/init().md)
- [lock()](coredata/nsmanagedobjectcontext/lock().md)
- [unlock()](coredata/nsmanagedobjectcontext/unlock().md)
