<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/OSAllocatedUnfairLock/precondition(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os21OSAllocatedUnfairLockV12preconditionyyAC9OwnershipOyx_GF"
  },
  "title" : "precondition(_:)"
}
-->

# precondition(_:)

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

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

## Parameters

`condition`

The ownership status to check.

## 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`](/documentation/os/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`](/documentation/os/OSAllocatedUnfairLock/Ownership/notOwner), the app terminates if the calling code doesn’t own the lock, or if the object isn’t locked.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)