2

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Asbis
  • 432
  • 5
  • 16
  • 2
    Read about completion blocks in Swift. That's exactly what you're looking for. – Paweł Kuźniak Sep 02 '16 at 17:18
  • This looks like what you're doing: http://stackoverflow.com/questions/37685777/firebase-retrieve-image-from-url-save-with-firebase-database – Don Sep 02 '16 at 17:24

1 Answers1

5

You have to use a closure.

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

func funcB(completion: () -> Void) {
    completion()
}
Marco Santarossa
  • 4,058
  • 1
  • 29
  • 49