<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSUserActivity/typedPayload(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So14NSUserActivityC7SwiftUIE12typedPayloadyxxmKSeRzSERzlF"
  },
  "title" : "typedPayload(_:)"
}
-->

# typedPayload(_:)

Decodes the user activity’s user info dictionary as an instance of the specified type.

```
func typedPayload<T>(_ type: T.Type) throws -> T where T : Decodable, T : Encodable
```

## Parameters

`type`

The type to decode from [`userInfo`](/documentation/Foundation/NSUserActivity/userInfo). The `type` must conform to <doc://com.apple.documentation/documentation/Swift/Codable>.

## Return Value

The type-safe instance.

## Discussion

> Important:
> This method applies only to SwiftUI apps.

Use this method to retrieve information from the user activity’s [`userInfo`](/documentation/Foundation/NSUserActivity/userInfo) dictionary in a type-safe manner.

If the type can’t be decoded from the [`userInfo`](/documentation/Foundation/NSUserActivity/userInfo) dictionary, this method throws [`NSUserActivity.TypedPayloadError.invalidContent`](/documentation/Foundation/NSUserActivity/TypedPayloadError/invalidContent).

---

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)