Required Instance Methodswift 6.0.1Swift

    decodeIfPresent(_:forKey:)

    Decodes a value of the given type for the given key, if present.

    func decodeIfPresent(_ type: Int.Type, forKey key: Self.Key) throws -> Int?

    Parameters

    type

    The type of value to decode.

    key

    The key that the decoded value is associated with.

    Returns

    A decoded value of the requested type, or nil if the Decoder does not have an entry associated with the given key, or if the value is a null value.

    Throws

    DecodingError.typeMismatch if the encountered encoded value is not convertible to the requested type.

    This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

    Other requirements

    View members

    Hide members

    This section is hidden by default because it contains too many (42) members.

    Type members

    Instance members

    Citizens in Swift

    Default implementations