NSWritingToolsCoordinator
An object that manages interactions between Writing Tools and your custom text view.
Declaration
@MainActor class NSWritingToolsCoordinatorMentioned in
Overview
Add a NSWritingToolsCoordinator object to a custom view when you want to add Writing Tools support to that view. The coordinator manages interactions between your view and the Writing Tools UI and back-end capabilities. When creating a coordinator, you supply a delegate object to respond to requests from the system and provide needed information. Your delegate delivers your view’s text to Writing Tools, incorporates suggested changes back into your text storage, and supports the animations that Writing Tools creates to show the state of an operation.
Create the NSWritingToolsCoordinator object when setting up your UI, and initialize it with a custom object that adopts the NSWritingToolsCoordinator.Delegate protocol. Add the coordinator to the writingToolsCoordinator property of your view. When a coordinator is present on a view, the system adds UI elements to initiate Writing Tools operations.
When defining the delegate, choose an object from your app that has access to your view and its text storage. You can adopt the NSWritingToolsCoordinator.Delegate protocol in the view itself, or in another type that your view uses to manage content. During the interactions with Writing Tools, the delegate gets and sets the contents of the view’s text storage and supports Writing Tools behaviors.
Topics
Creating a coordinator object
Checking the availability of Writing Tools
Managing Writing Tools interactions
Getting the host views for effects
Configuring the experience
Reporting changes to Writing Tools
updateRange(_:with:reason:forContextWithIdentifier:)updateForReflowedTextInContextWithIdentifier(_:)NSWritingToolsCoordinator.TextUpdateReason
Managing the current state
Getting the supporting types
NSWritingToolsCoordinator.ContextScopeNSWritingToolsCoordinator.TextReplacementReasonNSWritingToolsCoordinator.TextAnimation