Enumeration
AttributeDynamicLookup
iOS 15.0+
iPadOS 15.0+
Mac Catalyst 15.0+
macOS 12.0+
tvOS 15.0+
watchOS 8.0+
A type to support dynamic member lookup of attributes and containers.
@dynamicMemberLookup @frozen enum AttributeDynamicLookup
Overview
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
Subscripts
subscript<T>(T.Type) -> TReturns an attributed string key that corresponds to a specified type.subscript(dynamicMember:)Returns the attributed string key for a specified Foundation key path.
Relationships
Conforms To
Swift.BitwiseCopyable