Asbjørn Rørvik Asbjørn Rørvik - 3 months ago 7
iOS Question

Swift - How to call a function after a function is complete?

i am new in swift.
I have been trying to google around.

My question is, how can i call a function after a function is complete?
So far i am using a delay, but sometimes the delay is not in sync.

The problem i try to solve is to download a URL from firebase database, and then proceed to download a image from Firebase.

Answer

You have to use a closure.

func funcA() {
    funcB(){
        //Manage completion handler
    }
}

func funcB(completion: () -> Void) {
    completion()
}