在Swift 2中注册用户注册设置的更改?
发布时间:2020-12-14 05:50:32 所属栏目:百科 来源:网络整理
导读:我似乎没有找到关于registerUserNotificationSettings的任何文档超出了去年11月( here)生成的内容,但是我的旧代码在Xcode 7和Swift 2中似乎并不适合我。 我在App Delegate中有这个代码: let endGameAction = UIMutableUserNotificationAction()endGameActi
我似乎没有找到关于registerUserNotificationSettings的任何文档超出了去年11月(
here)生成的内容,但是我的旧代码在Xcode 7和Swift 2中似乎并不适合我。
我在App Delegate中有这个代码: let endGameAction = UIMutableUserNotificationAction() endGameAction.identifier = "END_GAME" endGameAction.title = "End Game" endGameAction.activationMode = .Background endGameAction.authenticationRequired = false endGameAction.destructive = true let continueGameAction = UIMutableUserNotificationAction() continueGameAction.identifier = "CONTINUE_GAME" continueGameAction.title = "Continue" continueGameAction.activationMode = .Foreground continueGameAction.authenticationRequired = false continueGameAction.destructive = false let restartGameCategory = UIMutableUserNotificationCategory() restartGameCategory.identifier = "RESTART_CATEGORY" restartGameCategory.setActions([continueGameAction,endGameAction],forContext: .Default) restartGameCategory.setActions([endGameAction,continueGameAction],forContext: .Minimal) application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert,.Badge,.Sound],categories: (NSSet(array: [restartGameCategory])) as Set<NSObject>)) 我现在在最后一行代码中收到以下两个错误:
和
我搜索了有关任何更改的信息,但我找不到任何内容。我错过了什么吗?
而不是使用(NSSet(array:[restartGameCategory]))将(NSSet(array:[restartGameCategory]))设置为Set< NSObject>设置< UIUserNotificationCategory>)像这样:
application.registerUserNotificationSettings( UIUserNotificationSettings( forTypes: [.Alert,categories: (NSSet(array: [restartGameCategory])) as? Set<UIUserNotificationCategory>)) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |