小编Mik*_*est的帖子

没有'+'候选人产生预期的上下文结果类型'NSNumber?' 斯威夫特3

在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?'

swift3 xcode8

4
推荐指数
1
解决办法
5660
查看次数

标签 统计

swift3 ×1

xcode8 ×1