AttributeDynamicLookup
A type to support dynamic member lookup of attributes and containers.
Declaration
@dynamicMemberLookup @frozen enum AttributeDynamicLookupOverview
This type allows attribute owners to add extensions that enable dynamic member lookup access to attributes. Supporting types — including AttributedString, AttributedSubstring, and AttributeContainer — gain dynamic lookup support by extending this type.
You can enable dynamic member lookup for your own AttributedStringKey attributes by defining them as implementations, collecting them into an AttributeScope and extending AttributeDynamicLookup, like in the following example:
public extension AttributeDynamicLookup {
subscript<T: AttributedStringKey>(dynamicMember keyPath: KeyPath<AttributeScopes.MyFrameworkAttributes, T>) -> T {
return self[T.self]
}
}Topics
Accessing Key Values
Accessing Framework Attribute Scopes
subscript(dynamicMember:)subscript(dynamicMember:)subscript(dynamicMember:)subscript(dynamicMember:)subscript(dynamicMember:)