var categories: NSSet = NSSet(object: firstCategory)
let types: UIUserNotificationType = UIUserNotificationType.Badge | UIUserNotificationType.Alert
没有工作,并说Binary运营商' |'无法应用于两个UIUserNotificationType'操作数
var categories: NSSet = NSSet(object: firstCategory)
var mySettings = UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge], categories: categories)
也没有用,并说无法分配类型' UIUserNotificationSettings.Type
的不可变表达式答案 0 :(得分:0)
尝试这样设置:
var categories: Set = Set(object: firstCategory)
UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert, UIUserNotificationType.Badge categories: categories))
答案 1 :(得分:0)
这应该有效:
var categories = Set(arrayLiteral: firstCategory)
var mySettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge], categories: categories)
你的第二行中有太多=
。此外,您需要使用Set
而不是NSSet
。