Hi everyone, I'm new to Swift, and I wrote two functions (just a multi-choice quiz app)
func createQuestions() // this goes to Parse, and fetches the questions data that are going to question the users and store them into local arrays
func newQuestion() // this also fetches some other data (for example, some incorrect choices) from Parse and read local variables and finally set the labels to correctly display to the users
I want to ViewDidLoad, first run createQuestion(), after it is fully completed, run newQuestion(). Otherwise, it newQuestion()has some problems reading from local variables that should have been extracted. How will I succeed? Thanks
EDIT: Thank you very much! I learned to use closure! Another follow-up question. I use the for loop to create questions. However, the problem is that the for loop does not execute in an orderly manner. Then my check for the re-function (vocabTestedIndices) fails, and this leads to two identical questions. I want the for loop to run one after another, so the questions you create will not overlap. Thanks!
code image
source
share