Dictionary

public extension Dictionary where Key: ExpressibleByStringLiteral

Convenience methods for reading from dictionaries without conditional casts.

Available where Key: ExpressibleByStringLiteral

  • 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, or nil if data contained is not convertible to a String.

  • 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] from

    Return 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, or nil if data contained is not convertible to an Int.

  • 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, or nil if data contained is not convertible to a Date.

  • Extracts the Entry at the specified fieldName.

    Declaration

    Swift

    func linkedEntry(at key: Key) -> Entry?

    Parameters

    key

    The name of the field to extract the Entry from.

    Return Value

    The Entry value, or nil if data contained does not have contain a Link referencing an Entry.

  • Extracts the Asset at the specified fieldName.

    Declaration

    Swift

    func linkedAsset(at key: Key) -> Asset?

    Parameters

    key

    The name of the field to extract the Asset from.

    Return Value

    The Asset value, or nil if data contained does not have contain a Link referencing an Asset.

  • Extracts the [Entry] at the specified fieldName.

    Declaration

    Swift

    func linkedEntries(at key: Key) -> [Entry]?

    Parameters

    key

    The name of the field to extract the [Entry] from.

    Return Value

    The [Entry] value, or nil if data contained does not have contain a Link referencing an Entry.

  • 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, or nil 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, or nil if data contained is not convertible to a Bool.

  • 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, or nil if data contained is not convertible to a Contentful.Location.