Contents

setTypedPayload(_:)

Encodes the specified payload into the user activity’s user info dictionary.

Declaration

func setTypedPayload<T>(_ payload: T) throws where T : Decodable, T : Encodable

Parameters

  • payload:

    The instance to convert to Userinfo. The type of the payload instance must conform to Codable.

Discussion

Use this method to set the user activity’s userInfo dictionary in a type-safe manner. After you set the userInfo dictionary using this approach, the keys in the userInfo dictionary match the coding keys from the Codable type you provide as the payload.

If the type can’t be encoded into the userInfo dictionary, this method throws NSUserActivity.TypedPayloadError.encodingError.

See Also

Managing type-safe access to user info