Dictionary
public extension Dictionary where Key: ExpressibleByStringLiteral
Convenience methods for reading from dictionaries without conditional casts.
-
Extract the String at the specified fieldName.
Declaration
Swift
func string(at key: Key) -> String?
Parameters
key
The name of the field to extract the
String
from.Return Value
The
String
value, ornil
if data contained is not convertible to aString
. -
Extracts the array of
String
at the specified fieldName.Declaration
Swift
func strings(at key: Key) -> [String]?
Parameters
key
The name of the field to extract the
[String]
fromReturn Value
The
[String]
, or nil if data contained is not convertible to an[String]
. -
Extracts the
Int
at the specified fieldName.Declaration
Swift
func int(at key: Key) -> Int?
Parameters
key
The name of the field to extract the
Int
value from.Return Value
The
Int
value, ornil
if data contained is not convertible to anInt
. -
Extracts the
Date
at the specified fieldName.Declaration
Swift
func int(at key: Key) -> Date?
Parameters
key
The name of the field to extract the
Date
value from.Return Value
The
Date
value, ornil
if data contained is not convertible to aDate
. -
Extracts the
[Asset]
at the specified fieldName.Declaration
Swift
func linkedAssets(at key: Key) -> [Asset]?
Parameters
key
The name of the field to extract the
[Asset]
from.Return Value
The
[Asset]
value, ornil
if data contained does not have contain a Link referencing an[Asset]
. -
Extracts the
Bool
at the specified fieldName.Declaration
Swift
func bool(at key: Key) -> Bool?
Parameters
key
The name of the field to extract the
Bool
value from.Return Value
The
Bool
value, ornil
if data contained is not convertible to aBool
. -
Extracts the
Contentful.Location
at the specified fieldName.Declaration
Swift
func location(at key: Key) -> Location?
Parameters
key
The name of the field to extract the
Contentful.Location
value from.Return Value
The
Contentful.Location
value, ornil
if data contained is not convertible to aContentful.Location
.