protocol
UnkeyedDecodingContainer
A type that provides a view into a decoder's storage and is used to hold the encoded properties of a decodable type sequentially, without keys.
Instance Variables
The path of coding keys taken to get to this point in decoding.
Declaration
var
codingPath
: [
CodingKey
]
The number of elements contained within this container.
If the number of elements is unknown, the value is nil
.
Declaration
var
count
:
Int
?
The current decoding index of the container (i.e. the index of the next element to be decoded.) Incremented after every successful decode call.
Declaration
var
currentIndex
:
Int
A Boolean value indicating whether there are no more elements left to be decoded in the container.
Declaration
var
isAtEnd
:
Bool
Instance Methods
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Bool
.
Type
)
throws
-
>
Bool
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
String
.
Type
)
throws
-
>
String
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Double
.
Type
)
throws
-
>
Double
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Float
.
Type
)
throws
-
>
Float
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Int
.
Type
)
throws
-
>
Int
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Int8
.
Type
)
throws
-
>
Int8
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Int16
.
Type
)
throws
-
>
Int16
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Int32
.
Type
)
throws
-
>
Int32
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
Int64
.
Type
)
throws
-
>
Int64
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt
.
Type
)
throws
-
>
UInt
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt8
.
Type
)
throws
-
>
UInt8
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt16
.
Type
)
throws
-
>
UInt16
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt32
.
Type
)
throws
-
>
UInt32
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt64
.
Type
)
throws
-
>
UInt64
Decodes a value of the given type.
- parameter type: The type of value to decode.
Declaration
mutating
func
decode
<
T
>
(
_
type
:
T
.
Type
)
throws
-
>
T
where
T
:
Decodable
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Bool
.
Type
)
throws
-
>
Bool
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
String
.
Type
)
throws
-
>
String
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Double
.
Type
)
throws
-
>
Double
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Float
.
Type
)
throws
-
>
Float
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int
.
Type
)
throws
-
>
Int
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int8
.
Type
)
throws
-
>
Int8
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int16
.
Type
)
throws
-
>
Int16
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int32
.
Type
)
throws
-
>
Int32
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int64
.
Type
)
throws
-
>
Int64
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt
.
Type
)
throws
-
>
UInt
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt8
.
Type
)
throws
-
>
UInt8
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt16
.
Type
)
throws
-
>
UInt16
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt32
.
Type
)
throws
-
>
UInt32
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt64
.
Type
)
throws
-
>
UInt64
?
Decodes a value of the given type, if present.
This method returns nil
if the container has no elements left to
decode, or if the value is null. The difference between these states can
be distinguished by checking isAtEnd
.
- parameter type: The type of value to decode.
Declaration
mutating
func
decodeIfPresent
<
T
>
(
_
type
:
T
.
Type
)
throws
-
>
T
?
where
T
:
Decodable
Decodes a null value.
If the value is not null, does not increment currentIndex.
Declaration
mutating
func
decodeNil
()
throws
-
>
Bool
Decodes a nested container keyed by the given type.
- parameter type: The key type to use for the container.
Declaration
mutating
func
nestedContainer
<
NestedKey
>
(
keyedBy
type
:
NestedKey
.
Type
)
throws
-
>
KeyedDecodingContainer
<
NestedKey
>
where
NestedKey
:
CodingKey
Decodes an unkeyed nested container.
Declaration
mutating
func
nestedUnkeyedContainer
()
throws
-
>
UnkeyedDecodingContainer
Decodes a nested container and returns a Decoder
instance for decoding
super
from that container.
Declaration
mutating
func
superDecoder
()
throws
-
>
Decoder
Decoders should provide types conforming to
UnkeyedDecodingContainer
for their format.