---
title: UISelectionFeedbackGenerator
framework: uikit
role: symbol
role_heading: Class
path: uikit/uiselectionfeedbackgenerator
---

# UISelectionFeedbackGenerator

A concrete feedback generator subclass that creates haptics to indicate a change in selection.

## Declaration

```swift
@MainActor class UISelectionFeedbackGenerator
```

## Overview

Overview Use selection feedback to communicate movement through a series of discrete values. For example, you might trigger selection feedback to indicate that a UI element’s values are changing. The following code example shows how to play selection feedback in response to a long-press gesture. var feedback = UISelectionFeedbackGenerator()

override func viewDidLoad() {     super.viewDidLoad()          // Create a selection feedback object and associate it with the view.     feedback = UISelectionFeedbackGenerator(view: view)          // Add a custom long-press gesture to the view.     let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress(_:)))     longPressGesture.numberOfTouchesRequired = 2     view.addGestureRecognizer(longPressGesture) }

@objc private func longPress(_ sender: UILongPressGestureRecognizer) {     if sender.state == .began {         // Play selection feedback to indicate a selection change.         feedback.selectionChanged(at: sender.location(in: view))                  // Update the UI in response to a selection change.         // ...     } } For more information, read Playing haptic feedback in your app.

## Topics

### Reporting selection changes

- [selectionChanged()](uikit/uiselectionfeedbackgenerator/selectionchanged().md)
- [selectionChanged(at:)](uikit/uiselectionfeedbackgenerator/selectionchanged(at:).md)

## Relationships

### Inherits From

- [UIFeedbackGenerator](uikit/uifeedbackgenerator.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UIInteraction](uikit/uiinteraction.md)

## See Also

### Haptic feedback

- [Playing haptic feedback in your app](applepencil/playing-haptic-feedback-in-your-app.md)
- [UIFeedbackGenerator](uikit/uifeedbackgenerator.md)
- [UIImpactFeedbackGenerator](uikit/uiimpactfeedbackgenerator.md)
- [UINotificationFeedbackGenerator](uikit/uinotificationfeedbackgenerator.md)
- [UICanvasFeedbackGenerator](uikit/uicanvasfeedbackgenerator.md)
