Skip to content

AnyCodable

mattpolzin edited this page Oct 1, 2020 · 3 revisions

AnyCodable

A type-erased Codable value.

public struct AnyCodable

The AnyCodable type forwards encoding and decoding responsibilities to an underlying value, hiding its specific underlying type.

You can encode or decode mixed-type values in dictionaries and other collections that require Encodable or Decodable conformance by declaring their contained type to be AnyCodable.

Inheritance

CustomDebugStringConvertible, CustomStringConvertible, Decodable, Encodable, Equatable

Initializers

init(_:)

public init<T>(_ value: T?)

init(from:)

public init(from decoder: Decoder) throws

init(nilLiteral:)

public init(nilLiteral _: ())

init(booleanLiteral:)

public init(booleanLiteral value: Bool)

init(integerLiteral:)

public init(integerLiteral value: Int)

init(floatLiteral:)

public init(floatLiteral value: Double)

init(stringLiteral:)

public init(stringLiteral value: String)

init(arrayLiteral:)

public init(arrayLiteral elements: Any)

init(dictionaryLiteral:)

public init(dictionaryLiteral elements: (AnyHashable, Any))

Properties

value

let value: Any

description

var description: String

debugDescription

var debugDescription: String

Methods

encode(to:)

public func encode(to encoder: Encoder) throws

==(lhs:rhs:)

public static func ==(lhs: AnyCodable, rhs: AnyCodable) -> Bool
Types
Protocols
Global Functions
Extensions

Clone this wiki locally