changes made
This commit is contained in:
parent
6263720e3d
commit
a6ee9ca775
@ -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
|
/// 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] {
|
func dictionaryForKey(_ key: String) -> [String: Any] {
|
||||||
|
|
||||||
guard let key = key as? Key else { return [:] }
|
return optionalDictionaryForKey(key) ?? [:]
|
||||||
|
|
||||||
return self[key] as? [String: Any] ?? [:]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a String after looking up the specified key. An empty string will be returned if a string for the key does not exist
|
/// 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 {
|
func stringForkey(_ key: String) -> String {
|
||||||
|
|
||||||
guard let key = key as? Key else { return "" }
|
return optionalStringForKey(key) ?? ""
|
||||||
|
|
||||||
return self[key] as? String ?? ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a String after looking up the specified key. Nil will be returned if a string for the key does not exist
|
/// 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
|
/// 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] {
|
func arrayForKey(_ key: String) -> [Any] {
|
||||||
|
|
||||||
guard let key = key as? Key else { return [] }
|
return optionalArrayForKey(key) ?? []
|
||||||
|
|
||||||
return self[key] as? [Any] ?? []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func optionalArrayForKey(_ key: String) -> [Any]? {
|
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
|
/// Return a Bool after looking up the specified key. This will return false if the key does not exist
|
||||||
func boolForKey(_ key: String) -> Bool {
|
func boolForKey(_ key: String) -> Bool {
|
||||||
|
|
||||||
guard let key = key as? Key else { return false }
|
return optionalBoolForKey(key) ?? false
|
||||||
|
|
||||||
return self[key] as? Bool ?? false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a Bool after looking up the specified key. This will return false if the key does not exist
|
/// 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 }
|
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 {
|
func lenientBoolForKey(_ key: String) -> Bool {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user