I extracted some HTML code and it's stored in a string called "html".
I want to pull the number of stars from this HTML code. Looking at the
html, I thought the easiest way was to look for the word "stars" in the
html string and go from there. So I wrote this code:
Code Block var s = "stars" if (html.contains(s)) { print("Found stars") }
However, for some reason this does not work and it does not print
"Found Stars" in the bottom right part of xcode. What am I doing wrong?
@oofmeister27
In your code, the completion closure (from line 1 { data, response, error in till line 14 }) is executed after the communication is completed.
But your line 16 through line 25 are executed before the communication is completed.
Move everything using the result of the communication into the completion closure.
Seems you are struggling with the same async problem.How can I fix this?
In your code, the completion closure (from line 1 { data, response, error in till line 14 }) is executed after the communication is completed.
But your line 16 through line 25 are executed before the communication is completed.
Move everything using the result of the communication into the completion closure.