<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntentsTesting",
  "identifier" : "/documentation/AppIntentsTesting/DynamicPropertyPath/as(_:)-5po1a",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "App Intents Testing"
    ],
    "preciseIdentifier" : "s:17AppIntentsTesting19DynamicPropertyPathV2asyxxmK0aB11TypeSupport22IntentValueConvertibleRzlF"
  },
  "title" : "as(_:)"
}
-->

# as(_:)

Casts a property to the provided type.

```
func `as`<T>(_ type: T.Type) throws -> T where T : IntentValueConvertible
```

## Discussion

If the value’s type doesn’t match,
this method throws an error.

```swift
let result = try await intent.run()
try result.value.as(String.self) == "My Name"
```

---

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)