A container for attribute keys and values.
``AttributeContainer`` provides a way to store attributes and their values outside of an attributed string. You
use this type to initialize an instance of ``AttributedString`` with preset attributes, and to set, merge, or
replace attributes in existing attributed strings.
Members (9)
get · iOS 15.0+
description
TypeScript
get description(): string
Swift declaration
var 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.
init(from decoder: any Decoder, configuration: AttributeScopeCodableConfiguration) throws
Creates a new instance by retrieving the instance's data from the specified decoder with help from the provided configuration.
- Parameters:
- decoder: The decoder to read data from.
- configuration: A decoding configuration instance that provides additional information necessary for decoding.
Merges the container's attributes with those in another attribute container.
- Parameters:
- other: The attribute container with the attributes to merge.
- mergePolicy: A policy to use when resolving conflicts between this string's attributes and those in `other`.
func encode(to encoder: any Encoder, configuration: AttributeScopeCodableConfiguration) throws
Encodes the value into the specified encoder with help from the provided configuration.
- Parameters:
- encoder: The encoder to write data to.
- configuration: An encoding configuration instance that provides additional information necessary for encoding.
Returns a copy of the attribute container with only attributes that have the provided run boundaries.
- Parameter runBoundaries: The required `runBoundaries` value of the filtered attributes. If `nil` is provided, only attributes not bound to any specific boundary will be returned.
- Returns: A copy of the attribute container with only attributes whose `runBoundaries` property matches the provided value.
Returns a copy of the attribute container with only attributes that specify the provided inheritance behavior.
- Parameter inheritedByAddedText: An `inheritedByAddedText` value to filter. Attributes matching this value are included in the returned container.
- Returns: A copy of the attribute container with only attributes whose `inheritedByAddedText` property matches the provided value.
Returns an attribute container by merging the container's attributes with those in another attribute container.
- Parameters:
- other: The attribute container with the attributes to merge.
- mergePolicy: A policy to use when resolving conflicts between this string's attributes and those in `other`.
- Returns: An attribute container created by merging the source container's attributes with those in another attribute container.
Creates an attribute container from a dictionary, using default attribute scopes.
- Parameter dictionary: A dictionary of attribute keys and their values.
This initializer includes all attribute scopes defined by the SDK, such as
`FoundationAttributes`, `SwiftUIAttributes`, and `AccessibilityAttributes`. To use
third-party attribute scopes, use the initializers ``AttributeContainer/init(_:including:)-2mw0o``
and ``AttributeContainer/init(_:including:)-28n0g``.
Skipped declarations
6 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
AttributeContainer.subscript(_:)
Passing a Swift type itself is not supported.
AttributeContainer.subscript(dynamicMember:)
This declaration needs Swift generic type arguments. (no canonical witness for K)
AttributeContainer.subscript(dynamicMember:)
Passing a Swift type itself is not supported.
AttributeContainer.subscript(dynamicMember:)
This declaration needs Swift generic type arguments. (no canonical witness for K)