---
title: "typedPayload(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsuseractivity/typedpayload(_:)"
---

# typedPayload(_:)

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

## Declaration

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

## Parameters

- `type`: The type to decode from doc://com.apple.foundation/documentation/Foundation/NSUserActivity/userInfo. The type must conform to doc://com.apple.documentation/documentation/Swift/Codable.

## Return Value

Return Value The type-safe instance.

## Discussion

Discussion important: This method applies only to SwiftUI apps. Use this method to retrieve information from the user activity’s userInfo dictionary in a type-safe manner. If the type can’t be decoded from the userInfo dictionary, this method throws NSUserActivity.TypedPayloadError.invalidContent.

## See Also

### Managing type-safe access to user info

- [setTypedPayload(_:)](foundation/nsuseractivity/settypedpayload(_:).md)
- [NSUserActivity.TypedPayloadError](foundation/nsuseractivity/typedpayloaderror.md)
