我正在尝试在本地通知时获得挂起的通知请求。它抛出错误:“从类型的抛出函数'(_)到非抛函数类型的无效转换”(UNNotificationRequest) -> Void‘"
我的代码是:
var notificationTitle = "\(String(describing: notificationData!["title"]))"
var notificationInterval: Int = notificationData!["interval"] as! Int
let center  =  UNUserNotificationCenter.current()
center.getPendingNotificationRequests(completionHandler: {(requests) -> Void in
    var notificationExist:Bool = false
    for notificationRequest in requests {
        try{
            var notificationContent:UNNotificationContent = notificationRequest.content
        }
    }发布于 2018-05-02 07:14:36
问题在于你的尝试块。因此,您可以替换它,如下所示。
guard let notificationContent:UNNotificationContent = try? notificationRequest.content else {
    print("There was an error!")
}https://stackoverflow.com/questions/50128723
复制相似问题