I'm new to app development and have inherited a project which I am currently updating to Swift 2.1.
I've cleaned up all compile errors except this last one, and need some help. The section of code I'm having problems with is as follows:
if application.respondsToSelector("registerUserNotificationSettings:") {
let testAction = UIMutableUserNotificationAction()
testAction.identifier = "TEST_ACTION"
testAction.title = "Reply"
testAction.activationMode = .Background
testAction.authenticationRequired = false
testAction.destructive = false
let category = UIMutableUserNotificationCategory()
category.identifier = "CATEGORY_ID"
category.setActions([testAction], forContext: .Default)
category.setActions([testAction], forContext: .Minimal)
let categories = NSSet(object: category) as! Set<UIUserNotificationCategory>
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: categories)
application.registerUserNotificationSettings(settings)
}
The line...
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: categories)
diplays this error: cannot convert value of type ‘Set<UIUserNotificationCategory>’ to expected argument type ‘Set<UIUserNotificationCategory>?’
And the line...
let categories = NSSet(object: category) as! Set<UIUserNotificationCategory>
displays the warning: Cast from ‘NSSet’ to unrelated type ‘Set<UIUserNotificationCategory>’ always fails
Using Xcode version 7.1 (7B91b)
Any help solving this problem with me would be greatly appreciated!!!