-1

I semi-recently updated to Xcode 7 and IOS9 but I am encountering an issue. When I try to follow tutorials, I am told to add this line of code:

let notificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound

However, this causes an error that says "Binary operator cannot be applied to two UIUserNotificationType operands." If anyone knows a work-around to this I would very much appreciate some help.

Nio Pullus
  • 55
  • 1
  • 7

1 Answers1

0

With Swift 2, Apple has added OptionSetType's. Use an array of options values instead of boolean operations like OR.

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

EDIT: I think a better way to express this would be the following.

let notificationType: UIUserNotificationType = [.Alert, .Badge, .Sound]
Price Ringo
  • 3,424
  • 1
  • 19
  • 33
  • Now I am getting an another issue. "Cannot call value of non function type '[UILocalNotification]'" for :UIApplication.sharedApplication().scheduledLocalNotifications(UINotification) – Nio Pullus Sep 17 '15 at 23:06