поэтому он может обрабатывать отсутствие конкретного параметра в ответ и установить значение как

ользуюCodable протокол от Swift 4 в первый раз, я не могу понять использованиеdecodeIfPresent изDecodable.

/// Decodes a value of the given type for the given key, if present.
///
/// 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.
///
/// - parameter type: The type of value to decode.
/// - parameter 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.
public func decodeIfPresent(_ type: String.Type, forKey key: KeyedDecodingContainer.Key) throws -> String?

Здесь это предполагает, что это возвращаетnil, если значение отсутствует со связанным ключом. Если это единственная причина, то чем она отличается от необязательного свойства, так как необязательной переменной также присваивается значениеnil если значение не присутствует в ответе.

Ответы на вопрос(2)

Ваш ответ на вопрос