Answer the question
In order to leave comments, you need to log in
How to pass values from a callback function in swift 3?
Hi all.
There is a variable var menus: Any = []
in which you need to write data from here
self.httpRequest.getJsonMenu(){ code in
print("Menu2: \(code)")
return code
}
Answer the question
In order to leave comments, you need to log in
Declared a variable var menus: Any = []
globally
PS Most likely my fault, I did not explain the question correctly .. This function performed an asynchronous request
Solving the problem by translating a variable into a global scope is a bad option, in terms of application architecture. If architecture is not important to you - then ¯\_(ツ)_/¯
So what's the question?
You have an array in a closure doing array.append(result)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question