diff --git a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift index 5f1c096..0ffad8d 100644 --- a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift +++ b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift @@ -54,17 +54,13 @@ public extension Dictionary { /// Returns a Dictionary after looking up the specified key. An empty dictionary is returned if a dictionary for the key does not exist func dictionaryForKey(_ key: String) -> [String: Any] { - guard let key = key as? Key else { return [:] } - - return self[key] as? [String: Any] ?? [:] + return optionalDictionaryForKey(key) ?? [:] } /// Returns a String after looking up the specified key. An empty string will be returned if a string for the key does not exist func stringForkey(_ key: String) -> String { - guard let key = key as? Key else { return "" } - - return self[key] as? String ?? "" + return optionalStringForKey(key) ?? "" } /// Returns a String after looking up the specified key. Nil will be returned if a string for the key does not exist @@ -76,9 +72,7 @@ public extension Dictionary { /// Returns an Array after looking up the specified key. An empty array will be returned if an array for the key does not exist func arrayForKey(_ key: String) -> [Any] { - guard let key = key as? Key else { return [] } - - return self[key] as? [Any] ?? [] + return optionalArrayForKey(key) ?? [] } func optionalArrayForKey(_ key: String) -> [Any]? { @@ -91,9 +85,7 @@ public extension Dictionary { /// Return a Bool after looking up the specified key. This will return false if the key does not exist func boolForKey(_ key: String) -> Bool { - guard let key = key as? Key else { return false } - - return self[key] as? Bool ?? false + return optionalBoolForKey(key) ?? false } /// Return a Bool after looking up the specified key. This will return false if the key does not exist @@ -101,7 +93,7 @@ public extension Dictionary { guard let key = key as? Key else { return nil } - return self[key] as? Bool ?? nil + return self[key] as? Bool } func lenientBoolForKey(_ key: String) -> Bool {