Dictionary

public extension Dictionary
extension Dictionary: InitializeableOccupiable
  • Helper method to modify value at specific key

    Declaration

    Swift

    mutating func modifyValue(atKey key: Key, _ modifyValue: (_ element: inout Value?) throws -> ()) rethrows
  • Returns a new dictionary containing the keys of this dictionary with the values transformed by the given closure. Filters out keys with nil values.

    Declaration

    Swift

    func compactMapValues<T>(_ transform: (Dictionary.Value) throws -> T?) rethrows -> [Dictionary.Key : T]

    Parameters

    transform

    A closure that transforms a value. transform accepts each value of the dictionary as its parameter and returns a transformed value of the same or of a different type.

    Return Value

    A dictionary containing keys and transformed values of this dictionary.

  • Returns a new dictionary containing the values of this dictionary with the keys transformed by the given closure.

    Declaration

    Swift

    func mapKeys(_ transform: (Dictionary.Key) throws -> Dictionary.Key) rethrows -> [Dictionary.Key : Dictionary.Value]

    Parameters

    transform

    A closure that transforms a key.

    Return Value

    A dictionary containing transformed keys and values.

  • Map keys and values together into a new dictionary.

    Warning

    Resulting keys must be unique!

    Declaration

    Swift

    @inlinable
    func mapDictionary<T, U>(_ transform: (_ key: Key, _ value: Value) throws -> (key: T, U)) rethrows -> [T : U] where T : Hashable

Values for key

  • Undocumented

    Declaration

    Swift

    func int(forKey key: Key) -> Int?
  • Undocumented

    Declaration

    Swift

    func double(forKey key: Key, defaultValue: Double) -> Double
  • Undocumented

    Declaration

    Swift

    func double(forKey key: Key) -> Double?
  • Undocumented

    Declaration

    Swift

    func bool(forKey key: Key) -> Bool?
  • Undocumented

    Declaration

    Swift

    func string(forKey key: Key, defaultValue: String) -> String
  • Undocumented

    Declaration

    Swift

    func string(forKey key: Key) -> String?
  • Undocumented

    Declaration

    Swift

    func date(forKey key: Key) -> Date?
  • Undocumented

    Declaration

    Swift

    func url(forKey key: Key) -> URL?
  • Undocumented

    Declaration

    Swift

    func data(forKey key: Key) -> Data?
  • Undocumented

    Declaration

    Swift

    func dictionary(forKey key: Key) -> [String : Any]?
  • Undocumented

    Declaration

    Swift

    func arrayOfInts(forKey key: Key) -> [Int]?
  • Undocumented

    Declaration

    Swift

    func arrayOfDoubles(forKey key: Key) -> [Double]?
  • Undocumented

    Declaration

    Swift

    func arrayOfBools(forKey key: Key) -> [Bool]?
  • Undocumented

    Declaration

    Swift

    func arrayOfStrings(forKey key: Key) -> [String]?
  • Undocumented

    Declaration

    Swift

    func arrayOfDictionaries(forKey key: Key) -> [[String : Any]]?