Ahhh, OpenFoodFacts and their types...
This commit is contained in:
@@ -8,4 +8,15 @@ extension KeyedDecodingContainer {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func decodeStringOrInt(forKey key: Key) throws -> Int? {
|
||||
if let intVal = try? decode(Int.self, forKey: key) {
|
||||
return intVal
|
||||
}
|
||||
if let stringVal = try? decode(String.self, forKey: key) {
|
||||
return Int(stringVal)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user