From 21a01cc9efd1c88d6044c831c89e4fef20be2a2b Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 18 Apr 2019 11:09:17 -0400 Subject: [PATCH 1/2] optional array --- MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift index cab84d0..46dbc01 100644 --- a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift +++ b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift @@ -52,6 +52,10 @@ public extension Dictionary { return array } + func optionalArrayForChainOfKeysOrIndexes(_ keysOrIndexes: [Any]) -> [Any]? { + return objectChainOfKeysOrIndexes(keysOrIndexes) as? [Any] + } + /// 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] { @@ -76,6 +80,10 @@ public extension Dictionary { return arrayForChainOfKeysOrIndexes([key]) } + func optionalArrayForKey(_ key : String) -> [Any]? { + return optionalArrayForChainOfKeysOrIndexes([key]) + } + /// Return a Bool after looking up the specified key. This will return false if the key does not exist func boolForKey(_ key : String) -> Bool { From 8322a5ab50e296113213fdfd96b7e3d0515d9c53 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 23 Apr 2019 14:50:26 -0400 Subject: [PATCH 2/2] array litterals --- MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift index 46dbc01..f5e402e 100644 --- a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift +++ b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift @@ -80,8 +80,11 @@ public extension Dictionary { return arrayForChainOfKeysOrIndexes([key]) } - func optionalArrayForKey(_ key : String) -> [Any]? { - return optionalArrayForChainOfKeysOrIndexes([key]) + func optionalArrayForKey(_ key : String) -> [Any]? { + guard let key = key as? Key else { + return nil + } + return self[key] as? [Any] } /// Return a Bool after looking up the specified key. This will return false if the key does not exist