This commit is contained in:
Christiano, Kevin 2019-05-07 16:05:46 -04:00
parent 633cda9f9f
commit e199cd9c02

View File

@ -120,13 +120,16 @@ public extension Dictionary {
/// Return a float from a string created by looking up the specified key. This will return 0.0 if the key does not exist /// Return a float from a string created by looking up the specified key. This will return 0.0 if the key does not exist
func floatForKey(_ key: String) -> Float { func floatForKey(_ key: String) -> Float {
return Float(stringForkey(key)) ?? 0.0 guard let key = key as? Key else { return 0.0 }
return self[key] as? Float ?? 0.0
} }
func optionalCGFloatForKey(_ key: String) -> CGFloat? { func optionalCGFloatForKey(_ key: String) -> CGFloat? {
guard let float = Float(stringForkey(key)) else { return nil } guard let key = key as? Key else { return nil }
return CGFloat(float)
return self[key] as? CGFloat
} }
func floatFromStringForKey(_ key: String) -> Float { func floatFromStringForKey(_ key: String) -> Float {
@ -136,7 +139,9 @@ public extension Dictionary {
func int32ForKey(_ key: String) -> Int32 { func int32ForKey(_ key: String) -> Int32 {
return Int32(stringForkey(key)) ?? 0 guard let key = key as? Key else { return 0 }
return self[key] as? Int32 ?? 0
} }
private func objectChainOfKeysOrIndexes(_ keysOrIndexes: [Any]) -> Any? { private func objectChainOfKeysOrIndexes(_ keysOrIndexes: [Any]) -> Any? {