Merge branch 'develop' into feature/kevin

This commit is contained in:
Christiano, Kevin 2019-04-25 11:42:46 -04:00
commit 0ed0fb49d8
2 changed files with 28 additions and 2 deletions

View File

@ -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,13 @@ public extension Dictionary {
return arrayForChainOfKeysOrIndexes([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
func boolForKey(_ key : String) -> Bool {
@ -123,6 +134,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)

View File

@ -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,_ threshold: Float) -> Bool {
return (abs((a) - (b)) < threshold)
}
class func cgfequalwiththreshold(_ a: CGFloat ,_ b: CGFloat,_ threshold: CGFloat) -> Bool {
return (abs((a) - (b)) < threshold)
}
}