草庐IT

ios - UNUserNotificationCenterDelegate 委托(delegate)方法 "nearly matches optional requirement"

coder 2023-09-10 原文

我正在实现

func userNotificationCenter(_ center: UNUserNotificationCenter, 
    didReceive response: UNNotificationResponse, 
    withCompletionHandler completionHandler: () -> Void) {

但是我从编译器收到“几乎匹配可选要求”的警告。我的声明有什么问题?我直接从文档中复制了它!

最佳答案

这是@escaping 属性。它没有显示在文档中。但它显示在页眉中。这就是复制的地方!这是正确的声明:

func userNotificationCenter(_ center: UNUserNotificationCenter, 
    didReceive response: UNNotificationResponse, 
    withCompletionHandler completionHandler: @escaping () -> Void) {

关于ios - UNUserNotificationCenterDelegate 委托(delegate)方法 "nearly matches optional requirement",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39515899/

有关ios - UNUserNotificationCenterDelegate 委托(delegate)方法 "nearly matches optional requirement"的更多相关文章

随机推荐