2016-11-08 114 views
0

對於初學者的問題,請原諒我,我有一個完成處理函數的函數,但函數完成時不會調用它。任何提示?感謝完成處理程序不叫

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

而且在來電:

updateDailyLength(completion: { getMonthlyDistance() }) 

功能getMonthlyDistance()不會被調用。

回答

7

你需要從updateDailyLength

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


updateDailyLength(completion: { getMonthlyDistance() }) 

調用它需要調用完成處理的updateDailyLength()函數。一旦使用參數getMonthlyDistance()調用該函數,將調用它代替完成()