characters
TypeScriptget characters(): AttributedString_CharacterViewSwift declarationvar characters: AttributedString.CharacterView { get }The characters of the attributed string, as a view into the underlying string.
struct · iOS 15.0+ · SDK 27.1
@dynamicMemberLookup struct AttributedSubstringA portion of an attributed string. ``AttributedSubstring`` provides no-copy access to the contents of the string within the relevant range. The distinction between an ``AttributedString`` and an ``AttributedSubstring`` lets you distinguish between whether you're in possession of an entire string or just a slice of it. Because ``AttributedSubstring`` and ``AttributedString`` both conform to ``AttributedStringProtocol``, working with ranges of ``AttributedString`` is natural. Modifying attributes by range works the same as it does on the base string. If you use an ``AttributedSubstring`` to mutate its base ``AttributedString``, you must perform your mutation inline, as the following example shows: ```swift // Correct use of copying. attrStr[range].link = url // Incorrect use of AttributedString copy. Copies the referenced range of the base // AttributedString and mutates that. var substr = attrStr[range] substr.link = url ```
get characters(): AttributedString_CharacterViewSwift declarationvar characters: AttributedString.CharacterView { get }The characters of the attributed string, as a view into the underlying string.
get startIndex(): AttributedString_IndexSwift declarationvar startIndex: AttributedString.Index { get }The position of the first character in a nonempty attributed substring.
get description(): stringSwift declarationvar description: String { get }A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.
setAttributes(attributes: AttributeContainer): voidSwift declarationmutating func setAttributes(_ attributes: AttributeContainer)Sets the attributed substring's attributes to those in a specified attribute container. - Parameter attributes: The attribute container with the attributes to apply.
get unicodeScalars(): AttributedString_UnicodeScalarViewSwift declarationvar unicodeScalars: AttributedString.UnicodeScalarView { get }The Unicode scalars of the attributed string, as a view into the underlying string.
mergeAttributes(attributes: AttributeContainer, mergePolicy?: AttributedString_AttributeMergePolicy): voidSwift declarationmutating func mergeAttributes(_ attributes: AttributeContainer, mergePolicy: AttributedString.AttributeMergePolicy = .keepNew)Merges the attributed string's attributes with those in a specified attribute container. - Parameters: - attributes: The attribute container with the attributes to merge. - mergePolicy: A policy to use when resolving conflicts.
replaceAttributes(attributes: AttributeContainer, others: AttributeContainer): voidSwift declarationmutating func replaceAttributes(_ attributes: AttributeContainer, with others: AttributeContainer)Replaces the attributed substring's attributes with those in a specified attribute container. - Parameters: - attributes: The existing attributes to replace. - others: The new attributes to apply.
get base(): AttributedStringSwift declarationvar base: AttributedString { get }Returns the underlying attributed string that the attributed substring derives from.
get runs(): AttributedString_RunsSwift declarationvar runs: AttributedString.Runs { get }The attributed runs of the attributed string, as a view into the underlying string.
get utf8(): AttributedString_UTF8ViewSwift declarationvar utf8: AttributedString.UTF8View { get }A view of the attributed substring's contents as a collection of UTF-8 code units.
get utf16(): AttributedString_UTF16ViewSwift declarationvar utf16: AttributedString.UTF16View { get }A view of the attributed substring's contents as a collection of UTF-16 code units.
get endIndex(): AttributedString_IndexSwift declarationvar endIndex: AttributedString.Index { get }A substring's past-the-end position -- the position one greater than the last valid subscript argument.
static init(): AttributedSubstringSwift declarationinit()Creates an empty attributed substring.
4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
AttributedSubstring.subscript(_:)
This parameter hides a concrete Swift type.
AttributedSubstring.subscript(_:)
Passing a Swift type itself is not supported.
AttributedSubstring.subscript(dynamicMember:)
This declaration needs Swift generic type arguments. (no canonical witness for K)
AttributedSubstring.subscript(dynamicMember:)
Passing a Swift type itself is not supported.