Created
February 6, 2020 20:14
-
-
Save BetterProgramming/3f1bb8b940c5ca7e222ac64e60008495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Decoder { | |
func getContext(forKey key: String) -> Any? { | |
let infoKey = CodingUserInfoKey(rawValue: key)! | |
return userInfo[infoKey] | |
} | |
} | |
extension JSONDecoder { | |
func set(context: Any?, forKey key: String) { | |
let infoKey = CodingUserInfoKey(rawValue: key)! | |
userInfo[infoKey] = context | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment