---
title: "dispatchPrecondition(condition:)"
framework: dispatch
role: symbol
role_heading: Function
path: "dispatch/dispatchprecondition(condition:)"
---

# dispatchPrecondition(condition:)

Checks a dispatch condition necessary for further execution.

## Declaration

```swift
func dispatchPrecondition(condition: @autoclosure () -> DispatchPredicate)
```

## Parameters

- `condition`: A dispatch predicate for the current context to check.

## Discussion

Discussion Use this function to detect conditions about the current execution context that must prevent the program from proceeding even in shipping code. In playgrounds and -Onone builds (the default for Xcode’s Debug configuration): if condition evaluates to false, stop program execution in a debuggable state. In -O builds (the default for Xcode’s Release configuration): if condition evaluates to false, stop program execution. In -Ounchecked builds, condition is not evaluated, but the optimizer may assume that it would evaluate to true. Failure to satisfy that assumption in -Ounchecked builds is a serious programming error.

## See Also

### Dispatch Objects

- [DispatchObject](dispatch/dispatchobject.md)
- [DispatchPredicate](dispatch/dispatchpredicate.md)
- [Dispatch Objects](dispatch/dispatch-objects.md)
