I'm currently learning about callbacks in Swift and am trying to understand something very basic. I can't seem to find a straight answer on this anywhere.
I understand that if I do:
URLSession.dataTask(with: URLRequest) { data, response, error in }
it will perform an asynchronous network request, after which I can do my own work with the result in the completion handler.
However, let's say that I want to write my own function that does some sort of background task. Would simply having a closure as a parameter to the function (that gets called in the function body) be enough to make the function work asynchronously? Or would I have to get into calling GCD method(s) in the function body as well?