---
title: "require(toFail:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uigesturerecognizer/require(tofail:)"
---

# require(toFail:)

Creates a dependency relationship between the gesture recognizer and another gesture recognizer when the objects are created.

## Declaration

```swift
func require(toFail otherGestureRecognizer: UIGestureRecognizer)
```

## Parameters

- `otherGestureRecognizer`: Another gesture-recognizer object (an instance of a subclass of doc://com.apple.uikit/documentation/UIKit/UIGestureRecognizer).

## Discussion

Discussion This method works fine when gesture recognizers aren’t created elsewhere in the app — or in a framework — and the set of gesture recognizers remains the same. If you need to set up failure requirements lazily or in different view hierarchies, use gestureRecognizer(_:shouldRequireFailureOf:) and gestureRecognizer(_:shouldBeRequiredToFailBy:) instead. (Note that the shouldRequireFailure(of:) and shouldBeRequiredToFail(by:) methods let subclasses define class-wide failure requirements.) This method creates a relationship with another gesture recognizer that delays the current gesture recognizer’s transition out of UIGestureRecognizer.State.possible. The state that the current gesture recognizer transitions to depends on what happens with otherGestureRecognizer: If otherGestureRecognizer transitions to UIGestureRecognizer.State.failed, the current gesture recognizer transitions to its normal next state. If otherGestureRecognizer transitions to recognized or UIGestureRecognizer.State.began, the current gesture recognizer transitions to UIGestureRecognizer.State.failed. An example where this method might be called is when you want a single-tap gesture require that a double-tap gesture fail.

## See Also

### Related Documentation

- [shouldBeRequiredToFail(by:)](uikit/uigesturerecognizer/shouldberequiredtofail(by:).md)
- [shouldRequireFailure(of:)](uikit/uigesturerecognizer/shouldrequirefailure(of:).md)
