From 21a01cc9efd1c88d6044c831c89e4fef20be2a2b Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 18 Apr 2019 11:09:17 -0400 Subject: [PATCH 1/4] 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 77b78c1a518c35d4deac12c492799c279fea55b6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 22 Apr 2019 13:14:22 -0400 Subject: [PATCH 2/4] Helper functions Molecule List. Back to view instead of margins for stack due to background color issues. Standard Header View to margin for internal use. --- .../Categories/Dictionary+MFConvenience.swift | 7 +++++++ .../Helpers/MVMCoreGetterUtility+Extension.swift | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift index cab84d0..db72e11 100644 --- a/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift +++ b/MVMCore/MVMCore/Categories/Dictionary+MFConvenience.swift @@ -123,6 +123,13 @@ public extension Dictionary { return floatValue } + func optionalCGFloatForKey(_ key: String) -> CGFloat? { + guard let key = key as? Key else { + return nil + } + return self[key] as? CGFloat + } + func floatFromStringForKey(_ key:String) -> Float { let stringValue = stringForkey(key) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift index e37b2b5..fa2167d 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift @@ -10,10 +10,18 @@ import Foundation public extension MVMCoreGetterUtility { class func fequal(a: Float ,b: Float) -> Bool { - return (abs((a) - (b)) < Float.ulpOfOne) + return fequalwiththreshold(a, b, Float.ulpOfOne) } class func cgfequal(_ a: CGFloat ,_ b: CGFloat) -> Bool { - return (abs((a) - (b)) < CGFloat.ulpOfOne) + return cgfequalwiththreshold(a, b, CGFloat.ulpOfOne) + } + + class func fequalwiththreshold(_ a: Float,_ b: Float,_ c: Float) -> Bool { + return (abs((a) - (b)) < c) + } + + class func cgfequalwiththreshold(_ a: CGFloat ,_ b: CGFloat,_ c: CGFloat) -> Bool { + return (abs((a) - (b)) < c) } } From 8322a5ab50e296113213fdfd96b7e3d0515d9c53 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 23 Apr 2019 14:50:26 -0400 Subject: [PATCH 3/4] 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 From bb51ea245dca7944e39838da88a6f5208a2af71c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 24 Apr 2019 14:52:27 -0400 Subject: [PATCH 4/4] parameter rename --- .../Utility/Helpers/MVMCoreGetterUtility+Extension.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift index fa2167d..c5a6854 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility+Extension.swift @@ -17,11 +17,11 @@ public extension MVMCoreGetterUtility { return cgfequalwiththreshold(a, b, CGFloat.ulpOfOne) } - class func fequalwiththreshold(_ a: Float,_ b: Float,_ c: Float) -> Bool { - return (abs((a) - (b)) < c) + class func fequalwiththreshold(_ a: Float,_ b: Float,_ threshold: Float) -> Bool { + return (abs((a) - (b)) < threshold) } - class func cgfequalwiththreshold(_ a: CGFloat ,_ b: CGFloat,_ c: CGFloat) -> Bool { - return (abs((a) - (b)) < c) + class func cgfequalwiththreshold(_ a: CGFloat ,_ b: CGFloat,_ threshold: CGFloat) -> Bool { + return (abs((a) - (b)) < threshold) } }