我正在尝试获取有关本地通知的待处理通知请求。 它抛出我的错误: “从'(_) throws -> Void'类型的抛出函数到非抛出函数类型'([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
}
}
最佳答案
你可能想这样做,
center.getPendingNotificationRequests(completionHandler: {requests -> () in
var notificationExist:Bool = false
for notificationRequest in requests {
do {
var notificationContent:UNNotificationContent = try notificationRequest.content
}
catch {
print(error)
}
}
}
关于ios - 从类型 '(_) throws -> Void' 的抛出函数到非抛出函数类型的无效转换 '([UNNotificationRequest]) -> Void,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50128723/