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
keyThe name of the field to extract the
Stringfrom.Return Value
The
Stringvalue, ornilif data contained is not convertible to aString. -
Extracts the array of
Stringat the specified fieldName.Declaration
Swift
func strings(at key: Key) -> [String]?Parameters
keyThe 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
Intat the specified fieldName.Declaration
Swift
func int(at key: Key) -> Int?Parameters
keyThe name of the field to extract the
Intvalue from.Return Value
The
Intvalue, ornilif data contained is not convertible to anInt. -
Extracts the
Dateat the specified fieldName.Declaration
Swift
func int(at key: Key) -> Date?Parameters
keyThe name of the field to extract the
Datevalue from.Return Value
The
Datevalue, ornilif data contained is not convertible to aDate. -
Extracts the
[Asset]at the specified fieldName.Declaration
Swift
func linkedAssets(at key: Key) -> [Asset]?Parameters
keyThe name of the field to extract the
[Asset]from.Return Value
The
[Asset]value, ornilif data contained does not have contain a Link referencing an[Asset]. -
Extracts the
Boolat the specified fieldName.Declaration
Swift
func bool(at key: Key) -> Bool?Parameters
keyThe name of the field to extract the
Boolvalue from.Return Value
The
Boolvalue, ornilif data contained is not convertible to aBool. -
Extracts the
Contentful.Locationat the specified fieldName.Declaration
Swift
func location(at key: Key) -> Location?Parameters
keyThe name of the field to extract the
Contentful.Locationvalue from.Return Value
The
Contentful.Locationvalue, ornilif data contained is not convertible to aContentful.Location.
View on GitHub
Dictionary Extension Reference