F
F
FlooDwm2016-10-31 17:46:03
Swift
FlooDwm, 2016-10-31 17:46:03

How to populate an array in a function?

There is an array var Array =[String]() there is a function DownloadData() The array (self.Array.append(var)) should be filled in the function, but it is not filled. I output the array after the function is executed, it is empty. Why and how to fix this
? not applicable function returns nothing

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Semchenko, 2016-10-31
@0xcffaedfe

I still recommend reading the book on Swift, where you will find answers to many questions.
A5jFA8Q.png

M
ManWithBear, 2016-10-31
@ManWithBear

Use inout parameters. But that's pretty bad manners. The return value option is much better. And you can always return a tuple (tuple)

B
briahas, 2016-11-17
@briahas

The question was not asked correctly ... even, I would say, idiotically.
Rewrite the question (judging by your post above, you need to figure out how asynchronous threads work). But to do this, determine what you do not understand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question