Structures
The following structures are available globally.
-
A type-erased
Codable
value.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
orDecodable
conformance by declaring their contained type to beAnyCodable
.See also
AnyEncodable
See also
AnyDecodable
Declaration
Swift
public struct AnyCodable : Codable
extension AnyCodable: Equatable
extension AnyCodable: CustomStringConvertible
extension AnyCodable: CustomDebugStringConvertible
extension AnyCodable: ExpressibleByNilLiteral, ExpressibleByBooleanLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, ExpressibleByStringLiteral, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral
-
A type-erased
Decodable
value.The
AnyDecodable
type 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
Decodable
conformance 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 : Decodable
extension AnyDecodable: Equatable
extension AnyDecodable: CustomStringConvertible
extension AnyDecodable: CustomDebugStringConvertible
-
A type-erased
Encodable
value.The
AnyEncodable
type 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
Encodable
conformance 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 : Encodable
extension AnyEncodable: Equatable
extension AnyEncodable: CustomStringConvertible
extension AnyEncodable: CustomDebugStringConvertible
extension AnyEncodable: ExpressibleByNilLiteral, ExpressibleByBooleanLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, ExpressibleByStringLiteral, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral
-
An error type for keychain operations.
See moreDeclaration
Swift
public struct KeychainError : Error
-
A struct representation of a generic password item in the keychain.
The keychain query uses generic password for the item’s class, the
See moreserviceName
property for the item’s service, and theaccount
property for the item’s account name.Declaration
Swift
public struct KeychainItem
-
Struct representing a multipart attachment to a multipart form data request
See moreDeclaration
Swift
public struct MultipartAttachment : Equatable