Instance MethodFoundationEssentials
transform(updating:body:)
iOS 26.0+
iPadOS 26.0+
Mac Catalyst 26.0+
macOS 26.0+
tvOS 26.0+
visionOS 26.0+
watchOS 26.0+
Tracks the location of the provided range throughout the mutation closure, returning a new, updated range that represents the same effective locations after the mutation.
mutating func transform<E>(updating range: Range<AttributedString.Index>, body: (inout AttributedString) throws(E) -> Void) throws(E) -> Range<AttributedString.Index>? where E : Error
Parameters
rangeA range to track throughout the
bodyblock.bodyA mutating operation, or set of operations, to perform on this
AttributedString.
Return Value
The updated Range that is valid after the mutation has been performed, or nil if the mutation performed does not allow for tracking to succeed (such as replacing the provided inout variable with an entirely different AttributedString).