We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f939eef commit d570c2fCopy full SHA for d570c2f
NetworkStack.playground/Contents.swift
@@ -108,10 +108,11 @@ protocol ParserProtocol {
108
}
109
110
struct Parser {
111
-
+ let jsonDecoder = JSONDecoder()
112
+
113
func json<T: Decodable>(data: Data, completition: @escaping ResultCallback<T>) {
114
do {
- let result: T = try JSONDecoder().decode(T.self, from: data)
115
+ let result: T = try jsonDecoder.decode(T.self, from: data)
116
OperationQueue.main.addOperation { completition(.success(result)) }
117
118
} catch let parseError {
0 commit comments