Skip to content

Commit 3cb9330

Browse files
authoredMay 28, 2020
fix example correctness (#90)
motivation: make example more correct changes: update response in DispatchQueue.main
1 parent 8c24cff commit 3cb9330

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎Examples/LocalDebugging/MyApp/MyApp/ContentView.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ struct ContentView: View {
6565
throw CommunicationError(reason: "invald response, empty body")
6666
}
6767
let response = try JSONDecoder().decode(Response.self, from: data)
68-
self.response = response.message
68+
self.setResponse(response.message)
6969
} catch {
70-
self.response = "\(error)"
70+
self.setResponse("\(error)")
7171
}
7272
}
7373
task.resume()
7474
}
75+
76+
func setResponse(_ text: String) {
77+
DispatchQueue.main.async {
78+
self.response = text
79+
}
80+
}
7581
}
7682

7783
struct ContentView_Previews: PreviewProvider {

0 commit comments

Comments
 (0)
Please sign in to comment.