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
  • 499,950
  • 69
  • 739
  • 734
Asbis
  • 352
  • 3
  • 13
  • 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
  • 3,973
  • 1
  • 26
  • 47