> On Sep 13, 2015, at 23:56, Brent Royal-Gordon <
br...@architechies.com> wrote:
>
> Closures natively support modifying variables captured from the scope they're in; there's nothing special you need to do to make that work.
I hoped it was that easy. This seemed an odd thing for Swift to not handle.
> However, many APIs that take a completion closure do it because they perform an operation asynchronously—that is, the operation isn't finished by the time myFrameworkFunction returns and the next line of code executes. Is that true of your function?
Yes, that's exactly it. The framework is pulling data from the internet, and does so asynchronously.
> If so, there's just no (easy) way to fill in resultsToReturn by the time that return statement executes, and you'll have to restructure your code so that the completion blocks continue the operation.
Sounds like fun. Thanks for the answer, at least my original question had a simple solution. Were the function not asynchronous, then, my example would work as expected.