Contents

transform(updating:body:)

Tracks the location of the selection throughout the mutation closure, updating the selection so it represents the same effective locations after the mutation.

Declaration

mutating func transform<E>(updating selection: inout AttributedTextSelection, body: (inout AttributedString) throws(E) -> Void) throws(E) where E : Error

Parameters

  • selection:

    The selection to track throughout the body closure.

  • body:

    A mutating operation, or set of operations, to perform on the value of self. The value of self is provided to the closure as an inout AttributedString that the closure should mutate directly. Do not capture the value of self in the provided closure - the closure should mutate the provided inout copy.

Discussion