Keymappable

Undocumented

  • mapped(_:key:) Extension method

    Maps the content of value for key in dictionary to generic type T, conforming to Serializable protocol.

    Declaration

    Swift

    public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Decodable

    Parameters

    dictionary

    An optional dictionary containing values which should be parsed.

    key

    ValueForKey will be called on the dictionary to extract the value to be parsed

    Return Value

    A mapped object conforming to , or nil if parsing failed

  • mapped(_:key:) Extension method

    Maps the content of value for key in dictionary to an array containing where elements is of generic type T, conforming to Serializable protocol.

    Declaration

    Swift

    public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Sequence, T.Iterator.Element: Decodable

    Parameters

    dictionary

    An optional dictionary containing values which should be parsed.

    key

    ValueForKey will be called on the dictionary to extract the value to be parsed.

    Return Value

    An array of mapped objects conforming to , or an empty array if parsing failed.

  • mapped(_:key:) Extension method

    A generic mapping function that will try to parse primitive types from the provided dictionary. Currently supported types are Int, Float, Double, Bool, Char and String.

    The key parameter will be first used to check value in custom input key mappings and if no value is found, then key is used as the key to get the value stored in dictionary.

    Declaration

    Swift

    public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T?

    Parameters

    dictionary

    An optional dictionary containing values which should be parsed.

    key

    The key which will be used to get the actual key from input key mappings or as the actual key for the value being parsed from the dictionary.

    Return Value

    The value of primitive type T or nil if parsing was unsuccessful.

  • mapped(_:key:) Extension method

    A generic mapping function that will try to parse an object of type T from the string value contained in the provided dictionary.

    The key parameter will be first used to check value in custom input key mappings and if no value is found, then key is used as the key to get the value stored in dictionary.

    Declaration

    Swift

    public func mapped<T:StringInitializable>(_ dictionary: NSDictionary?, key: String) -> T?

    Parameters

    dictionary

    An optional dictionary containing the array which should be parsed.

    key

    The key which will be used to get the actual key from input key mappings or as the actual key for the value being parsed from the dictionary.

    Return Value

    The value of type T or nil if parsing was unsuccessful.

  • mapped(_:key:) Extension method

    A generic mapping function that will try to parse enumerations with raw value from the provided dictionary.

    This function internally uses a variant of the generic mapped() function used to parse primitive types, which means that only enums with raw value of primitive type are supported.

    The key parameter will be first used to check value in custom input key mappings and if no value is found, then key is used as the key to get the value stored in dictionary.

    Declaration

    Swift

    public func mapped<T:RawRepresentable>(_ dictionary: NSDictionary?, key: String) -> T?

    Parameters

    dictionary

    An optional dictionary containing values which should be parsed.

    key

    The key which will be used to get the actual key from input key mappings or as the actual key for the value being parsed from the dictionary.

    Return Value

    The enumeration of enum type T or nil if parsing was unsuccessful or enumeration does not exist.

  • mapped(_:key:) Extension method

    A generic mapping function that will try to parse an array of enumerations with raw value from the array contained in the provided dictionary.

    The key parameter will be first used to check value in custom input key mappings and if no value is found, then key is used as the key to get the value stored in dictionary.

    Declaration

    Swift

    public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Sequence, T.Iterator.Element: RawRepresentable

    Parameters

    dictionary

    An optional dictionary containing the array which should be parsed.

    key

    The key which will be used to get the actual key from input key mappings or as the actual key for the value being parsed from the dictionary.

    Return Value

    An array of enum type T or an empty array if parsing was unsuccessful.

  • mapped(_:key:) Extension method

    A generic mapping function that will try to parse an object of type T from the hex string value contained in the provided dictionary.

    The key parameter will be first used to check value in custom input key mappings and if no value is found, then key is used as the key to get the value stored in dictionary.

    Declaration

    Swift

    public func mapped<T: HexInitializable>(_ dictionary: NSDictionary?, key: String) -> T?

    Parameters

    dictionary

    An optional dictionary containing the array which should be parsed.

    key

    The key which will be used to get the actual key from input key mappings or as the actual key for the value being parsed from the dictionary.

    Return Value

    The value of type T or nil if parsing was unsuccessful.