gpt4 book ai didi

Swift2 NotificationType 选项错误

转载 作者:行者123 更新时间:2023-12-02 08:27:33 27 4
gpt4 key购买 nike

将 Swift1.2 转换为 Swift2 后出现错误...不知道如何修复它,smb 在 Swift2 中试过这个吗?

func application(application: UIApplication, 
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

let notificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let settings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
application.registerUserNotificationSettings(settings)
return true
}

编辑:

Error: "Cannot find initialiser for type 'UIUserNotificationSettings' that accept an argument list of type '(forTypes:[UIUserNotifivati..."

最佳答案

只需从您的代码中更改这部分

let notificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]

进入:

let notificationType: UIUserNotificationType = [.Alert, .Badge, .Sound]

关于Swift2 NotificationType 选项错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30740410/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com