Why XCode doesn't see the variable?

Good day, there is a problem, make a request to the server, get the response as JSON, do JSON parsing and store it all in a variable
Alamofire.request("http://127.0.0.1:8000/api/auditOS/", method: .get).responseJSON { response in
 let jsonParse = JSON(response.result.value!)
print(jsonParse)
 }

But then the variable you want to use, but XCode says that such a variable does not exist, how can that be? tried to contact and through self - helps, he sees it only within the braces with Alamofire request, outside of them immediately throws the error. I would be grateful for an answer why is this happening and how to solve this problem)
June 26th 19 at 14:00
2 answers
June 26th 19 at 14:02
Solution
Judging from what you wrote, the answer is very simple: you declare a constant inside jsonParse circuit. Inside the circuit it can be seen. This problem can be solved by declaring a variable (var instead of let) outside of functions.
June 26th 19 at 14:04
Because here the asynchronous model and this variable can only be used as a e, where you have print.
Roughly speaking, this callback (most likely) will be executed in a different thread, in parallel, the code it, after it is created, so if CODM appealed to the variable, then the words would be nil.

Find more questions by tags Swift