Functions
The following functions are available globally.
-
Get a keyed decoding container using a coding key
Throws
DecodingError.typeMismatchif the encountered stored value is not a keyed container.Declaration
Swift
public func ~~> <K: CodingKey>(decoder: Decoder, keyType: K.Type) throws -> KeyedDecodingContainer<K>Parameters
decoderThe decoder
keyTypeThe key type
Return Value
A keyed container
-
Decode a value or object
Throws
DecodingError.typeMismatchif the encountered encoded value is not convertible to the requested type.Declaration
Swift
public func *> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> O where O : Decodable, K : CodingKeyReturn Value
The value or object
-
Decode a optional value or object
Throws
DecodingError.typeMismatchif the encountered encoded value is not convertible to the requested type.Declaration
Swift
public func ?*> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> O? where O : Decodable, K : CodingKeyReturn Value
The value or object
-
Decode an array
Throws
DecodingError.typeMismatchif the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.Throws
DecodingError.valueNotFoundif the encountered encoded value is null, or of there are no more values to decode.Declaration
Swift
public func **> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> [O] where O : Decodable, K : CodingKeyParameters
containerThe container
keyThe coding key
Return Value
An array of objects
-
Decode an array
Throws
DecodingError.typeMismatchif the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.Throws
DecodingError.valueNotFoundif the encountered encoded value is null, or of there are no more values to decode.Declaration
Swift
public func ?**> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> [O]? where O : Decodable, K : CodingKeyParameters
containerThe container
keyThe coding key
Return Value
An array of objects
-
Get a keyed encoding container using a coding key
Declaration
Swift
public func ~~> <K>(encoder: Encoder, keyType: K.Type) -> KeyedEncodingContainer<K> where K : CodingKeyParameters
encoderThe encoder
keyTypeThe key type
Return Value
A keyed container
-
Combine a coding key and a coding value
Declaration
Swift
public func <~~ <O, K>(key: K, value: O?) -> (key: K, value: O?) where O : Encodable, K : CodingKeyParameters
keyThe coding key
objectThe coding value
Return Value
The coding pair
-
Encode a value
Throws
EncodingError.invalidValueif the given value is invalid in the current context for this format.Declaration
Swift
public func <* <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>, pair: (key: K, value: O?)) throwsParameters
containerThe encoding container
pairThe key value pair that need to be encoded
-
Encode an optional value
Throws
EncodingError.invalidValueif the given value is invalid in the current context for this format.Declaration
Swift
public func <*? <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>, pair: (key: K, value: O?)) throwsParameters
containerThe encoding container
pairThe key value pair that need to be encoded
-
Encode an array
Throws
EncodingError.invalidValueif the given value is invalid in the current context for this format.Declaration
Swift
public func <** <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>, pair: (key: K, value: [O]?)) throwsParameters
containerThe encoding container
pairThe key value pair that need to be encoded
-
Encode an optional array
Throws
EncodingError.invalidValueif the given value is invalid in the current context for this format.Declaration
Swift
public func <**? <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>, pair: (key: K, value: [O]?)) throwsParameters
containerThe encoding container
pairThe key value pair that need to be encoded
-
Compare a string to a regex.
Declaration
Swift
public func ~= (regex: String, string: String) -> BoolParameters
stringThe string to be compared.
patternThe regex to be used
Return Value
Whether the regex can be found in the string or not.
Functions Reference