Class

CHHapticPattern

An object representing a haptic waveform.

Declaration

class CHHapticPattern : NSObject

Overview

A haptic pattern represents the waveform of a haptic through a hierarchical set of key-value pairs, starting at the topmost level with a CHHapticPattern.Key key. This key marks the beginning of an array of events and parameterID definitions. Each event has an associated time that indicates when the system will deliver the event to the haptic engine.

A diagram showing the contents of a pattern: its keys, values, and subdictionaries.

These key-value pairs represent not only events constituting the pattern, but also individual parameters of each event, which are characteristics of the haptic, such as sharpness and intensity. More complicated patterns also contain key-value pairs for parameter curves, which you can use to modulate parameters over time.

Topics

Creating a Haptic Pattern

init(events: [CHHapticEvent], parameterCurves: [CHHapticParameterCurve])

Constructs a haptic pattern from a series of events and parameter curves.

init(events: [CHHapticEvent], parameters: [CHHapticDynamicParameter])

Constructs a haptic pattern from a series of events and parameters.

init(dictionary: [CHHapticPattern.Key : Any])

Creates a haptic pattern from a property list dictionary.

struct CHHapticPattern.Key

The structural representation of a key to the pattern dictionary.

Retrieving Haptic Pattern Duration

var duration: TimeInterval

The duration of the haptic pattern, in seconds.

Exporting a Haptic Pattern

func exportDictionary() -> [CHHapticPattern.Key : Any]

Returns the dictionary representation of the haptic pattern.

Relationships

Inherits From

Conforms To

See Also

Essentials

Preparing Your App to Play Haptics

Set up your app to play haptics.

Playing a Single-Tap Haptic Pattern

Create and play a transient haptic pattern from a dictionary literal inline.

class CHHapticEngine

An object that manages your app's requests to play haptic patterns.