Other Objects
-
A type-erased
Codablevalue.The
AnyCodabletype 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
EncodableorDecodableconformance by declaring their contained type to beAnyCodable.See also
AnyEncodableSee moreSee also
AnyDecodableDeclaration
Swift
public struct AnyCodable : Codableextension AnyCodable: Equatableextension AnyCodable: CustomStringConvertibleextension AnyCodable: CustomDebugStringConvertibleextension AnyCodable: ExpressibleByNilLiteral, ExpressibleByBooleanLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, ExpressibleByStringLiteral, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral -
A type-erased
Decodablevalue.The
AnyDecodabletype forwards decoding responsibilities to an underlying value, hiding its specific underlying type.You can decode mixed-type values in dictionaries and other collections that require
Decodableconformance by declaring their contained type to beAnyDecodable:
See morelet json = """ { "boolean": true, "integer": 1, "double": 3.14159265358979323846, "string": "string", "array": [1, 2, 3], "nested": { "a": "alpha", "b": "bravo", "c": "charlie" } } """.data(using: .utf8)! let decoder = JSONDecoder() let dictionary = try! decoder.decode([String: AnyCodable].self, from: json)Declaration
Swift
public struct AnyDecodable : Decodableextension AnyDecodable: Equatableextension AnyDecodable: CustomStringConvertibleextension AnyDecodable: CustomDebugStringConvertible -
A type-erased
Encodablevalue.The
AnyEncodabletype forwards encoding responsibilities to an underlying value, hiding its specific underlying type.You can encode mixed-type values in dictionaries and other collections that require
Encodableconformance by declaring their contained type to beAnyEncodable:
See morelet dictionary: [String: AnyEncodable] = [ "boolean": true, "integer": 1, "double": 3.14159265358979323846, "string": "string", "array": [1, 2, 3], "nested": [ "a": "alpha", "b": "bravo", "c": "charlie" ] ] let encoder = JSONEncoder() let json = try! encoder.encode(dictionary)Declaration
Swift
public struct AnyEncodable : Encodableextension AnyEncodable: Equatableextension AnyEncodable: CustomStringConvertibleextension AnyEncodable: CustomDebugStringConvertibleextension AnyEncodable: ExpressibleByNilLiteral, ExpressibleByBooleanLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, ExpressibleByStringLiteral, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral -
Struct representing Respondable Info related values.
See moreDeclaration
Swift
public struct RespondableInfo : Codable, Equatable
View on GitHub
Other Objects Reference