我似乎無法找到超越製作去年十一月(here),但我的舊代碼似乎並沒有爲我在Xcode 7的工作更多的和registerUserNotificationSettings任何文件斯威夫特2.在Swift 2中更改registerUserNotificationSettings?
我有這個代碼在應用程序委託:
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>))
我現在收到的最後一行代碼以下兩個錯誤:
「Element.Protocol」沒有一個名爲「警告」
成員
和
不能援引「registerUserNotificationSettings」類型的參數列表「(UIUserNotificationSettings)」
我搜索過的任何變化的信息,但我找不到任何東西。我錯過了明顯的東西嗎?
這當然看起來比我原來的代碼更好看 - 謝謝@ 0x7fffffff。 –