---
title: "precondition(_:)"
framework: os
role: symbol
role_heading: Instance Method
path: "os/osallocatedunfairlock/precondition(_:)"
---

# precondition(_:)

Asserts if the lock object fails to meet specified ownership requirements.

## Declaration

```swift
func precondition(_ condition: OSAllocatedUnfairLock<State>.Ownership)
```

## Parameters

- `condition`: The ownership status to check.

## Discussion

Discussion Call this function to ensure the ownership state of the lock is what your code requires. For example, if you call this function and pass OSAllocatedUnfairLock.Ownership.owner, the app terminates if the object is locked, but the calling code doesn’t own the lock. Similarly, if you call it and pass OSAllocatedUnfairLock.Ownership.notOwner, the app terminates if the calling code doesn’t own the lock, or if the object isn’t locked.

## See Also

### Determining lock ownership

- [OSAllocatedUnfairLock.Ownership](os/osallocatedunfairlock/ownership.md)
