3
我實現UNUserNotificationCenterDelegate委託方法「幾乎可以與強制性要求」
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler:() -> Void) {
但我得到了「幾乎可以與可選的要求」,從編譯器警告。我的聲明有什麼問題?我將它從文檔中複製出來!
從[這裏]評論複製(http://stackoverflow.com/questions/39395513/how-to-handle-usernotifications-actions-in-ios-10/39426419? noredirect = 1#comment66238962_39426419):'@ escaping'的意思是「這個閉包可以稍後執行」。編譯器可以很容易地優化映射,過濾等常用的非轉義閉包,Swift 3已經將其設置爲默認值。所有完成處理程序在某些任務完成時執行 - 稍後,所以我們需要爲Swift 3中的所有完成處理程序註釋@escaping – Honey