Skip to content

Instance PropertyFoundationEssentials

unicodeScalars

iOS 15.0+ iPadOS 15.0+ Mac Catalyst 15.0+ macOS 12.0+ tvOS 15.0+ watchOS 8.0+
The Unicode scalars of the attributed string, as a view into the underlying string.
var unicodeScalars: AttributedString.UnicodeScalarView { get set }

Discussion

Use this property when you want to split the attributed string by Unicode scalar instead of grapheme cluster. This is useful when you need to carefully control insertion points or render the content.

You can also use this property to mutate the attributed string, using RangeReplaceableCollection methods, such as insert(_:at:) and append(_:). Inserted characters inherit any attributes present at the insertion point.