<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/AttributeDynamicLookup",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation22AttributeDynamicLookupO"
  },
  "title" : "AttributeDynamicLookup"
}
-->

# AttributeDynamicLookup

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`](/documentation/Foundation/AttributedString), [`AttributedSubstring`](/documentation/Foundation/AttributedSubstring), and [`AttributeContainer`](/documentation/Foundation/AttributeContainer) — gain dynamic lookup support by extending this type.

You can enable dynamic member lookup for your own [`AttributedStringKey`](/documentation/Foundation/AttributedStringKey) attributes by defining them as implementations, collecting them into an [`AttributeScope`](/documentation/Foundation/AttributeScope) and extending [`AttributeDynamicLookup`](/documentation/Foundation/AttributeDynamicLookup), like in the following example:

```swift
public extension AttributeDynamicLookup {
    subscript<T: AttributedStringKey>(dynamicMember keyPath: KeyPath<AttributeScopes.MyFrameworkAttributes, T>) -> T {
        return self[T.self]
    }
}
```

## Topics

### Accessing Key Values

[`subscript(_:)`](/documentation/Foundation/AttributeDynamicLookup/subscript(_:))

Returns an attributed string key that corresponds to a specified type.

### Accessing Framework Attribute Scopes

[`subscript(dynamicMember:)`](/documentation/Foundation/AttributeDynamicLookup/subscript(dynamicMember:)-3nor6)

Returns the attributed string key for a specified Foundation key path.

[`subscript(dynamicMember:)`](/documentation/Foundation/AttributeDynamicLookup/subscript(dynamicMember:)-3neai)

Returns the attributed string key for a specified Foundation number format key path.

[`subscript(dynamicMember:)`](/documentation/Foundation/AttributeDynamicLookup/subscript(dynamicMember:)-3q4ap)

Returns the attributed string key for a specified SwiftUI key path.

[`subscript(dynamicMember:)`](/documentation/Foundation/AttributeDynamicLookup/subscript(dynamicMember:)-4yyyo)

Returns the attributed string key for a specified UIKit key path.

[`subscript(dynamicMember:)`](/documentation/Foundation/AttributeDynamicLookup/subscript(dynamicMember:)-3v1cn)

Returns the attributed string key for a specified AppKit key path.

## Relationships

### Conforms To

[`Copyable`](/documentation/Swift/Copyable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)