One Logo Pool Ball
PencilKit · IOS API REFERENCE

PKStrokeRecognizer

class · iOS 27.0+ · SDK 27.1

final actor PKStrokeRecognizer

An actor that recognizes handwritten strokes and searches for text in a drawing.

Members (8)

method · iOS 27.0+

updateDrawing

TypeScript
updateDrawing(drawing: PKDrawing): Promise<void>
Swift declaration
final func updateDrawing(_ drawing: PKDrawing) async

Updates the drawing the recognizer analyzes. Recognition expects handwriting and strokes scaled as if written on standard paper sizes in points, such as US-letter or A4. - Parameter drawing: The new drawing.

method · iOS 27.0+

recognizedText

TypeScript
recognizedText(strokeIDs?: (Array<string>) | null): Promise<(string) | null>
Swift declaration
final func recognizedText(strokeIDs: Set<UUID>? = nil) async -> String?

Returns the recognized text from the specified strokes in the drawing. - Parameter strokeIDs: The `id`s of the `PKStrokes` in `drawing` to analyze. Pass `nil` to return the recognized text from the whole drawing.

get · iOS 27.0+

unownedExecutor

TypeScript
get unownedExecutor(): SDKHandle
Swift declaration
nonisolated final var unownedExecutor: UnownedSerialExecutor { get }

Retrieve the executor for this actor as an optimized, unowned reference. This property must always evaluate to the same executor for a given actor instance, and holding on to the actor must keep the executor alive. This property will be implicitly accessed when work needs to be scheduled onto this actor. These accesses may be merged, eliminated, and rearranged with other work, and they may even be introduced when not strictly required. Visible side effects are therefore strongly discouraged within this property. - SeeAlso: ``SerialExecutor`` - SeeAlso: ``TaskExecutor``

get · iOS 27.0+

indexableContent

TypeScript
get indexableContent(): Promise<(string) | null>
Swift declaration
final var indexableContent: String? { get async }

A string suitable for indexing the drawing's recognized text in search systems such as Spotlight. The string may contain multiple concatenated candidate matches for recognized text in the drawing. - Important: This query runs low-priority background recognition. Interactive queries can cancel it, in which case it returns nil. Use the indexing query when the person isn't interacting with the device.

init · iOS 27.0+

init

TypeScript
static init(preferredLanguages?: (Array<_Foundation_Locale_Language>) | null): PKStrokeRecognizer
Swift declaration
init(preferredLanguages: [Locale.Language]? = nil)

Creates a recognizer with the specified preferred languages. Languages are respected on a best-effort basis. Factors such as feature support may affect which languages the recognizer uses. - Parameters: - preferredLanguages: A list of languages to recognize ordered by descending priority. Pass nil to use the system languages. The system languages may be used if no listed language is available for recognition.

get · iOS 27.0+

recognitionVersion

TypeScript
static get recognitionVersion(): number
Swift declaration
static var recognitionVersion: Int { get }

The version number of the recognition engine. If you persist results this recognizer returns, store this value alongside them and regenerate the results when running on an OS with a higher version number.

get · iOS 27.0+

supportedLanguages

TypeScript
static get supportedLanguages(): Array<_Foundation_Locale_Language>
Swift declaration
static var supportedLanguages: Set<Locale.Language> { get }

The languages the recognizer supports.

method · iOS 27.0+

search

TypeScript
search(query: string, fullWordsOnly?: boolean, caseMatchingOnly?: boolean): Promise<Array<PKStrokeRecognizer_SearchResult>>
Swift declaration
final func search(_ query: String, fullWordsOnly: Bool = false, caseMatchingOnly: Bool = false) async -> [PKStrokeRecognizer.SearchResult]

Searches the drawing for strokes whose recognized text matches the query. - Parameters: - query: The query string to search for. - fullWordsOnly: Restricts matches to whole words only. - caseMatchingOnly: Restricts matches to exact case. - Returns: An array of all results found.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

PKStrokeRecognizer.drawing

The iOS SDK compiler rejected this binding: actor-isolated property 'drawing' can not be referenced from a nonisolated context

PKStrokeRecognizer.languages

The iOS SDK compiler rejected this binding: actor-isolated property 'languages' can not be referenced from a nonisolated context

All PencilKit types →