Taxi Noi Bai Ha Noi Taxi Noi Bai Ha Noi - 27 days ago 11
Swift Question

Completion handler is not called

Pardon me for beginner's question, I have this function with a completion handler, but it's not called when the function complete. Any tip? thanks

func updateDailyLength(completion: ()-> Void ) {
//do something here
}


And in the caller:

updateDailyLength(completion: { getMonthlyDistance() })


The function
getMonthlyDistance()
is never called.

Answer

You need to call it from updateDailyLength

func updateDailyLength(completion: ()-> Void ) {
      completion()
}
Comments