在Xcode 8和Swift 3上出现错误+我已尝试过任何事情,但没有结果.这里的代码:
static func addNotificationInterval(title: String, body: String,
indentifier: String, interval: Double) {
let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationString(forKey: title, arguments: nil)
content.body = NSString.localizedUserNotificationString(forKey: body, arguments: nil)
content.sound = UNNotificationSound.default()
content.badge = UIApplication.shared.applicationIconBadgeNumber + 1; content.categoryIdentifier = "com.elonchan.localNotification"
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: interval, repeats: true)
let request = UNNotificationRequest.init(identifier: indentifier, content: content, trigger: trigger)
let center = UNUserNotificationCenter.current()
center.add(request)
print("SetNotifiInterval")
}
Run Code Online (Sandbox Code Playgroud)
错误来自+:
content.badge = UIApplication.shared.applicationIconBadgeNumber + 1; content.categoryIdentifier = "com.elonchan.localNotification"
Run Code Online (Sandbox Code Playgroud)
错误类型:
没有'+'候选人产生预期的上下文结果类型'NSNumber?'